Discussion Locked

.Bat file runs in window, not shortcut

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have written a dos .bat file to delete and copy some files. When I double click the .bat file, a dos window flashes on the screen, but the actions in the file dont get carried out. BUT, if I open a command prompt window, and drag the .bat file into that window the program runs perfectly. I am using XP Professional and the simple .bat file goes as follows:

echo off
del f:*.* /Q /s
xcopy "c:documents and settings\tomc\my documents\*.*" /s "f:\my documents" /y /v
exit

Any clue as yo whythis works the way it does, and can i get it to work from a click?

thanks a lot......

7 replies

by dklippert

You could create a shortcut that runs the bat file preceded by:
%windir%\System32\cmd.exe

by tpcosmo

Thats pretty close, that method just opened a command prompt window, with the title batfilename.bat.

Thnaks anyway.

by vinnyd

Create a shortcut with this command line:

%windir%\System32\cmd.exe /c batfilename.bat

by tpcosmo

Thats IT.......thanks a lot. The /c is the key to the shortcut. Otherwise it just openes up a command prompt window.

by steve penn

put a pause command at the end of the file.

you can then see what the batch file is doing.

maybe the box is closing before it can execute all the batch commands.

This discussion is closed to new replies.