以前在工作中遇到的一个问题,我们的产品在运行时,点击安装,会报错,找到一个结束进程的控件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
下载地址: 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