If process exists?
Can someone show me an example script of
If something.exe exists,
do something
I don't remember the plug-in or syntax for that
thank you
Archive: If process exists?
If process exists?
Can someone show me an example script of
If something.exe exists,
do something
I don't remember the plug-in or syntax for that
thank you
That's not plugin, it's the included LogicLib header (LogicLib.nsh).
A forum search should help you a lot.
Re: If process exists?
1.The FindProcDLL & KillProcDLL Plugins
FindProcDLL::FindProc "something.exe"
Pop $R0
IntCmp $R0 1 0 Next
MessageBox MB_ICONSTOP|MB_YESNO|MB_DEFBUTTON2 'The process "something.exe" is exist,do you want to kill it or quit?' IDYES +2
Abort
Next:
KillProcDLL::KillProc "something.exe"
2.The ProcessWork Plugin
Push $R9
Loop:
Push "something.exe"
ProcessWork::ExistsProcess
Pop $R0
IntCmp $R0 0 Done
MessageBox MB_RETRYCANCEL|MB_ICONSTOP 'The process "something.exe" is exist.click [retry] to stop it or [cancel] to cancel setup.' IDCANCEL Exit
Push "something.exe"
ProcessWork::KillProcess
Sleep 1000
Goto Loop
Exit:
Abort
Done:
Pop $R0
If you want to do different things while a file is exist or not,you can use the command "IfFileExist":
IfFileExist "$WINDIR\Notepad.exe" Exist Not
Exist:
;Something want to do if file exist
Not:
You can find it in NSIS Users Manual.
And the example using LogicLib. I prefer this cause it is little more structured.
${If} ${FileExists} "$WINDIR\Notepad.exe"
;something
${Else}
;semething else
${EndIf}