/*
nsProcess是NSIS查找应用程序进程的插件
nsProcess可以通过应用程序名来查找进程.
nsProcess可以关闭所有指定的进程名.
*/
!AddIncludeDir "../Include"
Name "nsProcessTest"
OutFile "nsProcessTest.exe"
!include "nsProcess.nsh"
!include "Sections.nsh"
!include "Logiclib.nsh"
Var RADIOBUTTON
Page components
Page instfiles
Section "Find process" FindProcess
${nsProcess::FindProcess} "Calc.exe" $R0
${If} $R0 == 0
MessageBox MB_OK "已经找到进程Calc.exe"
${Else}
MessageBox MB_OK "nsProcess::FindProcess$n$n
Errorlevel: [$R0]"
${EndIf}
${nsProcess::Unload}
SectionEnd
Section /o "Kill process" KillProcess
loop:
${nsProcess::FindProcess} "NoTePad.exe" $R0
StrCmp $R0 0 0 +2
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION 'Close "notepad" before continue' IDOK loop IDCANCEL end
${nsProcess::KillProcess} "NoTePad.exe" $R0
MessageBox MB_OK "nsProcess::KillProcess$n$n
Errorlevel: [$R0]"
Exec "notepad.exe"
Exec "notepad.exe"
Exec "notepad.exe"
BringToFront
MessageBox MB_OK "Press OK and 3 notepad's windows will be closed"
${nsProcess::KillProcess} "NoTePad.exe" $R0
MessageBox MB_OK "nsProcess::KillProcess$n$n
Errorlevel: [$R0]"
end:
${nsProcess::Unload}
SectionEnd
Function .onInit
StrCpy $RADIOBUTTON ${FindProcess}
FunctionEnd
Function .onSelChange
!insertmacro StartRadioButtons $RADIOBUTTON
!insertmacro RadioButton ${FindProcess}
!insertmacro RadioButton ${KillProcess}
!insertmacro EndRadioButtons
FunctionEnd
THE END
暂无评论内容