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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch File Hangs When Running .exe 1

Status
Not open for further replies.

gharabed

Programmer
Sep 7, 2001
251
US
Is there a way around this problem? If I start a cmd window and simply run any .exe file the prompt comes back to the window (as if the .exe process were spawned/forked). However, if I create a batch (.bat) file and put a command in that batch file to run the very same .exe file the batch file will hang until I terminate the called program (as if the batch file is running the program synchronously.) Why is this happening? Is there a way to fork a program from a batch file into the background?

For example, if I try to run Outlook in the batch file, it will start Outlook but the batch program will hang until I quit Outlook.

Any ideas?

Thanks,
Greg
 
Use the START command before calling the executable.

Example1:
@echo off
notepad
exit

This will launch notepad, but will keep the CMD/DOS window open until Notepad is closed. Now try this:

Example 2:
@echo off
start notepad
exit

This will launch Notepad, then immediately close the CMD/DOS window (assuming you're set the "Close window on exit" property).



------------------------
Doug J.
Winchester, VA
 
right on dcj2..i'll give ya a star for that one. :)

Also just like to add for other people who may have seen this - there's no need for a long 'ole path in there like "c:\program files\microsoft office\office\outlook.exe".
just create a simple .bat file containing:

start winword
exit

assuming your path is set, that will start MSword. You can substitute "outlook" for "winword", or any other program. Starts very quickly too. ...And who said Win2K doesn't support DOS batch files?? ;)

pbxman
Systems Administrator

Please let Tek-Tips members know their posts were helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top