Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


(Hopefully)An Easy Question

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,28464
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> (Hopefully)An Easy Question
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 (Hopefully)An Easy Question - 11/30/2005 7:43:30 AM   
  shaneras

 

Posts: 2
Score: 0
Joined: 11/30/2005
Status: offline
Hi all,

I am trying to create a simple script that deletes a folder using a system or user variable path. I can't seem to find any good examples searching online of how to do this. My code below returns 'path not found', any ideas how I can delete New Folder from the %tmp% variable path?

Dim fso, Folder2Delete
Folder2Delete = ("%tmp%")+"\New Folder"
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFolder(Folder2Delete)
WshShell.ExpandEnvironmentStrings("%tmp%")

 
 
Post #: 1
 
 RE: (Hopefully)An Easy Question - 11/30/2005 8:07:21 AM   
  ebgreen


Posts: 5069
Score: 31
Joined: 7/12/2005
Status: online
Folder2Delete =  WshShell.ExpandEnvironmentStrings("%tmp%") & "\New Folder"


Make sure that you instantiate the WshShell object before you try to use it:

Set WshShell = WScript.CreateObject("WScript.Shell")

(in reply to shaneras)
 
 
Post #: 2
 
 RE: (Hopefully)An Easy Question - 11/30/2005 8:15:11 AM   
  shaneras

 

Posts: 2
Score: 0
Joined: 11/30/2005
Status: offline
That did the trick, thanks ebgreen!!!

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: (Hopefully)An Easy Question - 12/2/2005 2:28:20 AM   
  mbouchard


Posts: 1916
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
An alternative way would be to use GetSpecialFolder, see the WSH docs for more info (Win folder and System folder)

Const TemporareyFolder = 2
Set fso = CreateObject("Scripting.FileSystemObject")
tempFolder = fso.GetSpecialFolder(TemporareyFolder)
msgbox tempFolder

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to shaneras)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> (Hopefully)An Easy Question Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts