|I have a vbs that runs an uninstall routine which works as expected with one minor exception. I cannot delete the folder that the vbs is called from. I have the coding in the vbs to run with elevated rights|
If WScript.Arguments.Named.Exists("elevated") = False Then
'Launch the script again as administrator
CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
I am closing the folder right away at the beginning of the script:
Set oShell = CreateObject("WScript.Shell")
And for good measure deleting the vbs itself towards the end and included a sleep before the folder is deleted.
objFSO.DeleteFolder "C:\folder1\", True
The error I am getting is access denied. I have correct rights as this runs fine if I were to launch if from C:\folder2 just not if it is lanched from C:\folder1. I'm at a loss as to why this would be since its the folder isnt open, isnt locked and is empty by the time I call the DeleteFolder. I additionally tried to add in the RD comment with the exact same results.
WshShell.Run "%COMSPEC% /C RD C:\folder1 /S /Q", 0