Dan*_*Dan 5 vbscript windows-installer visual-studio-2008
我需要在Windows安装程序项目(标准OOTB VS 2008安装程序项目-vdproj)中执行批处理文件作为卸载过程的一部分.无法直接从安装程序项目中的自定义操作执行bat文件,因此我编写了一个快速的vbs脚本来调用所需的bat文件.
vbs代码:
Set WshShell = WScript.CreateObject( "WScript.Shell" )
command = "uninstall-windows-serivce.bat"
msgbox command
WshShell.Run ("cmd /C " & """" & command & """")
Set WshShell = Nothing
Run Code Online (Sandbox Code Playgroud)
当此脚本独立于卸载运行时,它可以完美地运行.但是,当作为卸载的一部分运行时,它不会执行bat文件(但会显示消息框,因此我知道调用了vbs文件).没有报告错误(至少我可以告诉).为什么此脚本不能作为"卸载自定义操作"的一部分工作
小智 6
我遇到了同样的问题,问题是你不能在vbs文件中调用WScript - 你需要调用CreateObject
即.
Set WshShell = CreateObject( "WScript.Shell" )
command = "uninstall-windows-serivce.bat"
msgbox command
WshShell.Run ("cmd /C " & """" & command & """")
Set WshShell = Nothing
Run Code Online (Sandbox Code Playgroud)
在您的安装程序类中,您是否重写了 Uninstall 方法:
Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
MyBase.Uninstall(savedState)
'Shell to batch file here
End Sub
Run Code Online (Sandbox Code Playgroud)
其次,您是否限定了批处理文件的完整路径?
| 归档时间: |
|
| 查看次数: |
16330 次 |
| 最近记录: |