kulisncc
asked on
Need help with this simple vbs script
i want to be able to delete a folder located in %userprofile% and this is not working. Here is the code:
Dim FSO, Folder
set FSO=CreateObject("Scripting.FileSystemObject")
user=oShell.ExpandEnvironmentStrings("%UserName%")
Folder=user &"\StratECUpgrd"
FSO.DeleteFolder(Folder)
ASKER
dammit!! I knew it was something miniscule. i will try that. thanks
ASKER
didnt work, the directory is still there in the user's profile.
Sorry, I got called away, now back at keyboard.
Try this script on for size...
Try this script on for size...
Dim WshSysEnv, WshShell, strUser
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
strUser = oShell.ExpandEnvironmentStrings("%USERPROFILE%")
objFSO.DeleteFolder strUser & "\StratECUpgrd"
One more time.... >_<
Dim objFSO, oShell, strUser
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
strUser = oShell.ExpandEnvironmentStrings("%USERPROFILE%")
objFSO.DeleteFolder strUser & "\test"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well something is amiss because it is still not deleting this directory
Use my latest code (IS: 35758266), if you hadn't. The next to latest had a target directory of 'test' as I wanted to make sure all worked on my end before I posted here, and of course, I forgot to update it to 'StratECUpgrd' instead.
Which OS are you working on by the way? I ran successful tests of this with XP and Win7. Any errors that you are encountering?
Which OS are you working on by the way? I ran successful tests of this with XP and Win7. Any errors that you are encountering?
ASKER
yeah i changed the Dim FSO and delcared the other variables and it ran great. You are the man brotha - kisses.
Just kidding about the kisses dude - LOL
Just kidding about the kisses dude - LOL
Glad it all worked out there. Sorry for the constant code revisions... severe Friday brain here at work... -___-
Dim FSO, Folder, user