今天查一個問題,我們的產品在運行是,點擊安裝,會報錯,找到一個結束進程的控件processwork.dll
下載地址:
http://www.esanu.name/programs/NSISKillProcess.html 將processwork.dll放到Plugins目錄下,然后在NSIS代碼中加入如下函數:
Function CloseParentWithUserApproval
Push $5
loop:
push "*.exe"
processwork::existsprocess
pop $5
IntCmp $5 0 done
MessageBox MB_RETRYCANCEL|MB_ICONSTOP “Your process must be closed during this installation.$\r$\n Close your process now, or press Retry to automatically close and continue or press Cancel to cancel the installation entirely.“ IDCANCEL BailOut
push "*.exe"
processwork::KillProcess
Sleep 2000
Goto loop
BailOut:
Abort
done:
Pop $5
FunctionEnd