Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


This should be simple... :)

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> This should be simple... :)
  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 >>
 This should be simple... :) - 6/18/2008 7:19:42 AM   
  collierblc@yahoo.com

 

Posts: 5
Score: 0
Joined: 5/29/2008
Status: offline
I'm basically creating a login script on a Terminal Server (Server 2003 R@) that maps some drives and dumps the contents of the Temp folder, then remaps drives, creates Temp folder. Also, if it's a new account it'll create the Temp folder. The 1st script below is attached to my AD login for the user, but will NOT delete anything in the temp folder.  The second script work, but it prompts me to hit Y to confirm that I want to delete everything then it'll work. So, I created the top script to answer Y, but it runs through, but doesn't delete the contents of the Temp folder. Anyone see what I'm doing wrong? Would really like some help! Thanks
 
 
 
net use s: \\suncoastterm\suncoast
 
del /Y t:\temp\*.*
net use /delete t:
net use t: \\suncoastterm\temp$\%username%
md t:\temp
 
(Works, but need to hit Y to confirm)
net use s: \\suncoastterm\suncoast
 
del t:\temp\*.*
net use /delete t:
net use t: \\suncoastterm\temp$\%username%
md t:\temp

< Message edited by collierblc@yahoo.com -- 6/18/2008 7:21:15 AM >
 
 
Post #: 1
 
 RE: This should be simple... :) - 6/18/2008 7:24:16 AM   
  dm_4ever


Posts: 2665
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Did you try...

echo Y | del t:\temp\*

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to collierblc@yahoo.com)
 
 
Post #: 2
 
 RE: This should be simple... :) - 6/18/2008 7:34:22 AM   
  collierblc@yahoo.com

 

Posts: 5
Score: 0
Joined: 5/29/2008
Status: offline
Sweet that worked, but it only deleted the files and pictures I put in there. It didn't del the folders I created. I think there's a switch to trash everything, but I can't find it.

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: This should be simple... :) - 6/18/2008 2:01:23 PM   
  DiGiTAL.SkReAM


Posts: 1184
Score: 7
Joined: 9/6/2005
From: Florida, USA
Status: offline
To delete folders AND files, you will need to run two seperate commands:

The files are easy:

del t:\temp\*.* /q /f

For the folders, you have to use the FOR command to iterate through all of the subfolders:

for /d %D in (t:\temp\*) do @rd /s /q "%D"


Some purists might say that you can use the /s command arg on the del command to delte all files in any subfolders as well, but I have found that using RD to delete subdirs AND their files is actually faster.
And remember:  if you use the for command at a command prompt, the variable only has one percent sign.  INSIDE of a batch file, though, and %D needs to be written as %%D or else it won't work.
And if you are using rd, it is ALWAYS best to TEST FIRST AND MAKE BACKUPS!!!!! <-my rear-covering-disclaimer



_____________________________

"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury

(in reply to collierblc@yahoo.com)
 
 
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 >> This should be simple... :) 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