这是我的代码,它首先检查包含安装程序的文件夹,如果找到,运行卸载并删除卸载.exe(如果它仍然存在)。最后,它会删除文件夹本身。
Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set wshshell = wscript.CreateObject("WScript.Shell")
If objFSO.FolderExists("C:\Installer_3_00_00") Then
Set objFolder = objFSO.GetFolder("C:\Installer_3_00_00")
if objFSO.FileExists("C:\Installer_3_00_00\uninstall.exe") Then
Wshshell.run "C:\Installer_3_00_00\uninstall.exe -q"
End if
if objFSO.FileExists("C:\Installer_3_00_00\uninstall.exe") Then
Set objFile=objFSO.GetFile("C:\Installer_3_00_00\uninstall.exe")
objFile.Delete True
End if
objFolder.Delete True
Else
End If
Set objFSO = Nothing
问题是:它说权限被拒绝尝试删除文件或文件夹。我通过手动删除进行了交叉检查,它起作用了。我在这个论坛上搜索过类似的问题,但没有一个能帮助我解决这个特定问题。
任何建议将不胜感激。谢谢
Ps 我尝试在这里格式化我的代码,但我仍然无法正确格式化它。