I'm close to going insane. I have a configuration of code in VBS and it throws an error that should be logically impossible.
Check this code: (You need at least 10 reputation to post images. Well that sure is helpful.) http://i.stack.imgur.com/jjNDm.png
If the folder revFolder exists, then (force) delete it. That also means if the folder does not exist, no DeleteFolder will be executed. I literally have the folder in front of me, it's there, I can see it. It was created by the same code just a few lines up. FolderExists returns true so the folder exists. Yet it throws the error "Path not found".
What is going on? This must be a bug in VBS, right?
.FolderExists
tolerates the spurious "\", .DeleteFolder
doesn't:
>> WScript.Echo goFS.FolderExists("C:\Documents and Settings\eh\30643986\")
>> goFS.DeleteFolder "C:\Documents and Settings\eh\30643986\"
>>
-1
Error Number: 76
Error Description: Path not found
>> goFS.DeleteFolder "C:\Documents and Settings\eh\30643986"
>> WScript.Echo goFS.FolderExists("C:\Documents and Settings\eh\30643986")
>>
0
>>
Try something like this: https://msdn.microsoft.com/en-us/library/fyy7a5kt%28v=vs.110%29.aspx
Sometimes you need to use the Path.Combine function to properly format a file path (it'll use all the appropriate escape characters).
EDIT
Look for buildpath in this article: http://windowsitpro.com/scripting/understanding-vbscript-manipulating-files-filesystemobject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With