InstallShield 使用 VBScript 删除文件没有文件时 CustomAction 失败
卸载以前的安装(我使用 InstallShield 2009 构建的)时,我想在卸载结束时删除该程序所在的整个文件夹。我不知道如何使用自定义操作来做到这一点,因此使用下面的代码,我决定在安装开始后立即删除该文件。如果该程序已安装,则效果很好...但如果之前未安装,则会抛出错误 1701,因为显然该文件夹不存在!我不知道如何解决这个问题,而且我几乎不懂 VBScript。我开始执行 try-catch 来掩盖错误,但显然 VBScript 中不存在这种情况。
Dim fso, Folder2Delete
Folder2Delete = "C:\Program Files\MyProgramDir"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder(Folder2Delete)
那么,如何将自定义操作粘贴到 InstallShield 中的卸载中,或者如何将 VB 脚本设置为仅删除文件(如果存在)?或者最后一搏,当它不存在时我怎样才能让它不显示错误......?
非常感谢,这让我发疯!
When uninstalling a previous installation (that I'd built using InstallShield 2009), I wanted to delete the entire folder that the program was in at the end of the uninstall. I couldn't figure out how to do that using a Custom Aaction, so using the code below, I settled for deleting the file as soon as the installation starts. This works fine if the program was already installed... but if it wasn't installed before, it throws an error 1701 because, obviously, the folder didn't exist! I have no idea how to fix this issue and I know almost no VBScript. I started to do a try-catch to just gloss over the error, but apparently that doesn't exist in VBScript.
Dim fso, Folder2Delete
Folder2Delete = "C:\Program Files\MyProgramDir"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder(Folder2Delete)
So either, How can I stick a Custom Action into an uninstall in InstallShield, or how can I set the VB script to only delete a file if it exists? Or last ditch, how can I get it to not show an error when it doesn't exist... ?
Thanks a lot, this is driving me crazy!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试以下代码:
对于此自定义操作,您可以将操作数据(CustomActionData 属性)设置为:
这样您的操作将删除用户设置的任何安装路径。
You can try this code:
For this custom action you can then set the action data (CustomActionData property) to:
This way your action will delete whatever installation path your users set.