为什么我无法删除 "program files" 中的文件夹?
Why I can't delete a folder in "program files"?
我运行以下具有管理员权限的脚本:
Dim FSO
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Dim tempName, fullTempName, tempFolder
tempName = FSO.GetTempName
fullTempName = "c:\program files\" + tempName
Set tempFolder = fso.CreateFolder( fullTempName )
tempFolder.Attributes = 0
tempFolder.Delete( True )
我可以创建文件夹但不能删除它。我收到错误消息:
Microsoft VBScript runtime error: Permission denied.
译自德语:
Laufzeitfehler in Microsoft VBScript: Erlaubnis verweigert.
重置属性无效。它是 continue 16(只读)。为什么会出现此错误,我该如何解决?
我找到了以下解决方法。我将 "tempFolder.Delete" 行替换为:
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run wshShell.ExpandEnvironmentStrings( "%SystemRoot%\system32\cmd.exe /c rd """ & fullTempName & """" ), 0
我运行以下具有管理员权限的脚本:
Dim FSO
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")
Dim tempName, fullTempName, tempFolder
tempName = FSO.GetTempName
fullTempName = "c:\program files\" + tempName
Set tempFolder = fso.CreateFolder( fullTempName )
tempFolder.Attributes = 0
tempFolder.Delete( True )
我可以创建文件夹但不能删除它。我收到错误消息:
Microsoft VBScript runtime error: Permission denied.
译自德语:
Laufzeitfehler in Microsoft VBScript: Erlaubnis verweigert.
重置属性无效。它是 continue 16(只读)。为什么会出现此错误,我该如何解决?
我找到了以下解决方法。我将 "tempFolder.Delete" 行替换为:
Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run wshShell.ExpandEnvironmentStrings( "%SystemRoot%\system32\cmd.exe /c rd """ & fullTempName & """" ), 0