1. 程式人生 > >NSIS製作的安裝包殺掉正在執行程序的方法

NSIS製作的安裝包殺掉正在執行程序的方法

;This callback will be called when the installer is nearly finished initializing. If the '.onInit' function calls Abort, the installer will quit instantly
Function .onInit
KillProcDLL::KillProc "myprogram.exe"
FunctionEnd


;This callback is called when the user hits the 'cancel' button after the install has failed (if it could not extract a file, or the install script used the Abort command).
Function .onInstFailed
ExecShell "open" "$INSTDIRmyprogram.exe"
FunctionEnd


;This callback will be called when the uninstaller is nearly finished initializing. If the 'un.onInit' function calls Abort, the uninstaller will quit instantly. Note that this function can verify and/or modify $INSTDIR if necessary.
Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to uninstall $(^Name) and its componments?" IDYES NoAbort IDYES +2
  Abort
NoAbort:
KillProcDLL::KillProc "myprogram.exe"
FunctionEnd