.Bat Files
Author
Discussion

rustoni

Original Poster:

325 posts

296 months

Thursday 20th May 2004
quotequote all
I am pulling my hair out as i have written some simple bat files to clean and defrag my desktop on a weekly basis which work fine but when i try to write something similar for the laptop they seem to run and delete themselves or just loop ?

for example if i run "defrag c: -f" from the command line all is well but if i put this in a text doc and save it as a .bat file then it just loops and doesn't do anything ?

Any idea's ?

Thanks
Ian

NikB

1,834 posts

289 months

Thursday 20th May 2004
quotequote all
You probably need to add a command to open a windows cmd window first. Something like:

call cmd defrag c: -f

mashie

39 posts

278 months

Friday 21st May 2004
quotequote all
Tested defrag c: -f here.

In w2k it is an unrecognized program.

Works just fine in XP, both at cmd and batchfile.

warmfuzzies

4,327 posts

277 months

Friday 21st May 2004
quotequote all
Maybe I can help, I tried to do a services halt batch file, and the problem occured when I tried to rename a .txt to .bat the file then becam .txt.bat and it all went wobbly on me.

Make sure your file has the right extension on it, not the double like I ended up with.

Kevin.