Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

how to write a vbs script to delete C:\windows\temp files


  • Please log in to reply
6 replies to this topic

#1 carolebrewster

carolebrewster

  • Members
  • 26 posts
  • OFFLINE
  •  
  • Gender:Female
  • Local time:09:54 PM

Posted 27 January 2015 - 08:41 PM

I want to learn how to create a vbs script to delete Windows\temp files. Can anyone help me?


Edited by Orange Blossom, 28 January 2015 - 02:30 AM.
Moved to more appropriate forum. ~ OB


BC AdBot (Login to Remove)

 


#2 Datcoolguy

Datcoolguy

  • Members
  • 303 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:10:54 PM

Posted 27 January 2015 - 09:04 PM

why does it have to be VBS?


"If you don't understand how your computer works, you shouldn't be messing with it!"


#3 carolebrewster

carolebrewster
  • Topic Starter

  • Members
  • 26 posts
  • OFFLINE
  •  
  • Gender:Female
  • Local time:09:54 PM

Posted 27 January 2015 - 09:18 PM

Because I have to  run it on all of my library computers.  We have Insight Management software and it has been crashing and doing backups in  C:\Windows\temp and is using all of the hard drive space.   I just want to do a quick dump of the temp files, then I need to update the program to the newest version.  Would a batch file work and if so how to write that.



#4 Kilroy

Kilroy

  • BC Advisor
  • 3,479 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Launderdale, MN
  • Local time:07:54 PM

Posted 27 January 2015 - 10:13 PM

DEL C:\Temp\*.* /S /Q
DEL C:\Windows\Temp\*.* /S /Q


#5 D@nby

D@nby

  • Members
  • 16 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Canada
  • Local time:07:54 PM

Posted 28 January 2015 - 02:28 AM

I want to learn how to create a vbs script to delete Windows\temp files. Can anyone help me?

After years of frikin around with Win 7
I came up with my own version (not exactly a script)
 
Download and install BleachBit in regular mode.
I usually partition my HD into 3 sections
C:OS
D:DVD
E:Downloads
F:/Installed program files/
 
Shut down computer
Srart computer (tapping F8)
This will bring you to a DOS screen
Click on safe mode with command prompt.
Log in
CD\
del *.db /f/s/q enter
wait 2 minutes

this completely deletes your compact Data Bases, AgRobust etc

del *.pf /f/s/q enter

this deletes all your cached pre fetched files

Then ctrl+alt+del
start task manager
start new task (click on use admin)
browse to BleachBit installation
Go to the .exe file
Start BleachBit
Click every button except for :wipe clean space
Make sure under options , all drives are selected
Click on clean, then delete
takes two minutes
scroll down until you see done
There will be special operations that require a reboot
close all task manager operations
you will be brought back to the command prompt in DOS

repeat:
del *.db /f/s/q enter

ctrl+alt+del
will bring you back to task manager
choose shutdown

Wait a few seconds then start you computer.

Clean as a whistle

D@nby

#6 JohnnyJammer

JohnnyJammer

  • Members
  • 1,122 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:11:54 AM

Posted 28 January 2015 - 06:40 PM

I want to learn how to create a vbs script to delete Windows\temp files. Can anyone help me?

You mean somethign simple like so? I forgot to mention the files wont be in the recycle bin after the deletion takes place!

'Set the file system object
Set filesysobj = CreateObject("Scripting.FileSystemObject")
' set the folder target
Set folder = filesysobj.GetFolder("C:\Windows\Temp")
'set the collector (cof = collection of files)
Set cof = folder.Files
'start the for each loop
For Each file in cof
    'delete each file
    file.Delete
Next
'clean up
Set filesysobj = Nothing
Set folder = Nothing
Set cof = Nothing

Now create a GPO at logon and simpyl add this script and it will delete the files, ensure people ahve write access/delete access to that folder as well.


Edited by JohnnyJammer, 28 January 2015 - 06:42 PM.


#7 JohnnyJammer

JohnnyJammer

  • Members
  • 1,122 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:11:54 AM

Posted 02 February 2015 - 10:24 PM

So did the OP use this or........






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users