* version 2.4
+ added killing processes running under U3-directories on hostCleanUp (this helps with SysInternals package, where you can launch different apps and similar)
This commit is contained in:
parent
a7fa6a6932
commit
4bc5d3a0df
@ -4,7 +4,9 @@
|
|||||||
; ### ###
|
; ### ###
|
||||||
; ##########################################################################
|
; ##########################################################################
|
||||||
|
|
||||||
StepsAll = 0
|
KillTries = 10
|
||||||
|
|
||||||
|
StepsAll = 1
|
||||||
If runeje0 > 0
|
If runeje0 > 0
|
||||||
StepsAll++
|
StepsAll++
|
||||||
If regsvr0 > 0
|
If regsvr0 > 0
|
||||||
@ -37,6 +39,65 @@ Loop %runeje0%
|
|||||||
If runeje0 > 0
|
If runeje0 > 0
|
||||||
StepsPos++
|
StepsPos++
|
||||||
|
|
||||||
|
Progress % StepsPos*StepsStep, Checking running processes ...
|
||||||
|
|
||||||
|
EnumProcesses(procss)
|
||||||
|
StringSplit procs, procss, |
|
||||||
|
KillProcs0 = 0
|
||||||
|
Loop %U3_HOST_EXEC_PATH%, 2
|
||||||
|
U3HEP := A_LoopFileLongPath
|
||||||
|
Loop %U3_DEVICE_EXEC_PATH%, 2
|
||||||
|
U3DEP := A_LoopFileLongPath
|
||||||
|
Loop %U3_APP_DATA_PATH%, 2
|
||||||
|
U3ADP := A_LoopFileLongPath
|
||||||
|
Loop %A_ScriptFullPath%
|
||||||
|
ASFP := A_LoopFileLongPath
|
||||||
|
Loop %procs0%
|
||||||
|
{
|
||||||
|
CurProc := procs%A_Index%
|
||||||
|
CurFn := GetModuleFileNameEx(CurProc)
|
||||||
|
if (StrLen(CurFn) > 0)
|
||||||
|
{
|
||||||
|
Loop %CurFn%
|
||||||
|
{
|
||||||
|
CurFn := A_LoopFileLongPath
|
||||||
|
CurFnOnly := A_LoopFileName
|
||||||
|
}
|
||||||
|
if ( (CurFn <> ASFP) && ( (SubStr(CurFn, 1, StrLen(U3HEP)) = U3HEP) || (SubStr(CurFn, 1, StrLen(U3DEP)) = U3DEP) || (SubStr(CurFn, 1, StrLen(U3ADP)) = U3ADP) ) )
|
||||||
|
{
|
||||||
|
KillProcs0++
|
||||||
|
KillProcs%KillProcs0% := CurProc . "|" . CurFnOnly
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loop %KillProcs0%
|
||||||
|
{
|
||||||
|
OutIndex = %A_Index%
|
||||||
|
CurProc := KillProcs%A_Index%
|
||||||
|
SplitFirst(CurPID, CurFn, CurProc, "|")
|
||||||
|
|
||||||
|
Loop %KillTries%
|
||||||
|
{
|
||||||
|
Process Exist, %CurPID%
|
||||||
|
If ErrorLevel
|
||||||
|
ProgPID = %ErrorLevel%
|
||||||
|
Else
|
||||||
|
Break
|
||||||
|
|
||||||
|
If (A_Index < KillTries-1)
|
||||||
|
{
|
||||||
|
Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/KillTries))/KillProcs0, Stopping process ... %CurFn% [%CurPID%]
|
||||||
|
WinClose ahk_pid %ProgPID%, , 0
|
||||||
|
}
|
||||||
|
Else
|
||||||
|
{
|
||||||
|
Progress % StepsPos*StepsStep+StepsStep*(OutIndex-1.00+(A_Index/KillTries))/KillProcs0, Killing process ... %CurFn% [%CurPID%]
|
||||||
|
Process Close, %ProgPID%
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StepsPos++
|
||||||
|
|
||||||
If (U3_IS_DEVICE_AVAILABLE <> "true")
|
If (U3_IS_DEVICE_AVAILABLE <> "true")
|
||||||
{
|
{
|
||||||
; U3 stick not plugged in!!
|
; U3 stick not plugged in!!
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
#NoEnv
|
#NoEnv
|
||||||
#Include mb_EnvTools.ahk
|
#Include mb_EnvTools.ahk
|
||||||
#Include mb_IniTools.ahk
|
#Include mb_IniTools.ahk
|
||||||
|
#Include mb_ProcTools.ahk
|
||||||
#Include mb_RegTools.ahk
|
#Include mb_RegTools.ahk
|
||||||
#Include mb_TextTools.ahk
|
#Include mb_TextTools.ahk
|
||||||
U3HVer = 2.3
|
U3HVer = 2.4
|
||||||
U3HUUID = 0f90f88c-5e05-4cab-8c3a-e1c0112b06fd
|
U3HUUID = 0f90f88c-5e05-4cab-8c3a-e1c0112b06fd
|
||||||
|
|
||||||
U3_APP_DATA_PATH := EnvValue("U3_APP_DATA_PATH")
|
U3_APP_DATA_PATH := EnvValue("U3_APP_DATA_PATH")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
1 VERSIONINFO
|
1 VERSIONINFO
|
||||||
FILEVERSION 2,3,0,0
|
FILEVERSION 2,4,0,0
|
||||||
PRODUCTVERSION 2,3,0,0
|
PRODUCTVERSION 2,4,0,0
|
||||||
FILEOS 0x4
|
FILEOS 0x4
|
||||||
FILETYPE 0x1
|
FILETYPE 0x1
|
||||||
{
|
{
|
||||||
@ -10,12 +10,12 @@ BLOCK "StringFileInfo"
|
|||||||
BLOCK "040904b0"
|
BLOCK "040904b0"
|
||||||
{
|
{
|
||||||
VALUE "FileDescription", "U3Helper manages registry settings and data files of ordinary applications to make them U3-compatible. (see http://www.u3.com/ for more info)"
|
VALUE "FileDescription", "U3Helper manages registry settings and data files of ordinary applications to make them U3-compatible. (see http://www.u3.com/ for more info)"
|
||||||
VALUE "FileVersion", "2, 3, 0, 0"
|
VALUE "FileVersion", "2, 4, 0, 0"
|
||||||
VALUE "InternalName", "U3H"
|
VALUE "InternalName", "U3H"
|
||||||
VALUE "LegalCopyright", "(c)2007 Markus Birth <mbirth@webwriters.de>"
|
VALUE "LegalCopyright", "(c)2007 Markus Birth <mbirth@webwriters.de>"
|
||||||
VALUE "OriginalFilename", "U3Helper.exe"
|
VALUE "OriginalFilename", "U3Helper.exe"
|
||||||
VALUE "ProductName", "U3Helper"
|
VALUE "ProductName", "U3Helper"
|
||||||
VALUE "ProductVersion", "2, 3, 0, 0"
|
VALUE "ProductVersion", "2, 4, 0, 0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
53
mb_ProcTools.ahk
Normal file
53
mb_ProcTools.ahk
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
; BEGIN: borrowed from http://www.autohotkey.com/forum/viewtopic.php?p=54838#54838
|
||||||
|
EnumProcesses( byref r_pid_list )
|
||||||
|
{
|
||||||
|
if A_OSVersion in WIN_95,WIN_98,WIN_ME
|
||||||
|
{
|
||||||
|
Tooltip, This Windows version (%A_OSVersion%) doesn't support PID listing.
|
||||||
|
return, false
|
||||||
|
}
|
||||||
|
|
||||||
|
pid_list_size := 4*1000
|
||||||
|
VarSetCapacity( pid_list, pid_list_size )
|
||||||
|
|
||||||
|
status := DllCall( "psapi.dll\EnumProcesses", "uint", &pid_list, "uint", pid_list_size, "uint*", pid_list_actual )
|
||||||
|
if ( ErrorLevel or !status )
|
||||||
|
return, false
|
||||||
|
|
||||||
|
total := pid_list_actual//4
|
||||||
|
|
||||||
|
r_pid_list=
|
||||||
|
address := &pid_list
|
||||||
|
loop, %total%
|
||||||
|
{
|
||||||
|
r_pid_list := r_pid_list "|" ( *( address )+( *( address+1 ) << 8 )+( *( address+2 ) << 16 )+( *( address+3 ) << 24 ) )
|
||||||
|
address += 4
|
||||||
|
}
|
||||||
|
|
||||||
|
StringTrimLeft, r_pid_list, r_pid_list, 1
|
||||||
|
|
||||||
|
return, total
|
||||||
|
}
|
||||||
|
|
||||||
|
GetModuleFileNameEx( p_pid )
|
||||||
|
{
|
||||||
|
if A_OSVersion in WIN_95,WIN_98,WIN_ME
|
||||||
|
{
|
||||||
|
ToolTip, This Windows version (%A_OSVersion%) doesn't support process details.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
h_process := DllCall( "OpenProcess", "uint", 0x10|0x400, "int", false, "uint", p_pid )
|
||||||
|
if ( ErrorLevel or h_process = 0 )
|
||||||
|
return
|
||||||
|
|
||||||
|
name_size = 255
|
||||||
|
VarSetCapacity( name, name_size )
|
||||||
|
|
||||||
|
result := DllCall( "psapi.dll\GetModuleFileNameExA", "uint", h_process, "uint", 0, "str", name, "uint", name_size )
|
||||||
|
|
||||||
|
DllCall( "CloseHandle", h_process )
|
||||||
|
|
||||||
|
return, name
|
||||||
|
}
|
||||||
|
; END: borrowed from http://www.autohotkey.com/forum/viewtopic.php?p=54838#54838
|
Reference in New Issue
Block a user