Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BAT problems 1

Status
Not open for further replies.

nickjkay

Technical User
Sep 25, 2006
16
0
0
GB
I'm a complete noob at scripts, but I want to make one that deletes all the files on the desktop at loggin.

When I run
DEL /Q DESKTOP
from the CMD it works fine, however when I double click it nothing happens appart from the cmd screen flashing up for a split second-any help PLEASE!
 
Make a .bat file containing:

@echo off
cd %userprofile%
del /q desktop\*.*
exit

Save that somewhere other than desktop ;)
Create a shortcut to it in your startup folder.

Jock
 
Incredible-it works, I'l have to read up more on scrips
 
If I wanted to add DEL /Q C:\TEMP how would I get that to work? Also any suggested reading for beginers on scripts?
 
Just add it before the exit call and after the del /q desktop/*.*, on a new line.

That will delete the entire temp directory is that what you want or do you want to delete the contents but preserve the folder?



----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Just add that line before the exit line.

Buried in the MS Technet scripting library (which is very comprehensive) you will find:


But googling command line reference will get you a lot of useful hits as well.

You might also want to look into VBScript, if you need a programmable scripting facility. See the FAQ section of forum329.

Jock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top