WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

DOS

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Detect if a Winbatch Script was Launched from DOS Console

Keywords: 	 Detect DOS Console

Question:

Can a WinBatch script be made aware of how it was launch, e.g. via "Start -> Run" or via a console window on WinNT (or a DOS window on Win9x)?

I have a situation where a .BAT file is being run and it makes use of some compiled WinBatch scripts. To keep everything running synchronously, the "START /W" or "START /WAIT" command is being used to force the .BAT file to pause until the compiled WinBatch script has completed.

What I would like to be able to do is to have WinBatch be aware of the fact that it was launched "synchronously" via a console/DOS window have it be able to interact with the user via stdin/stdout/stderr in the console/DOS window.

Answer:

You could just have a flag file in your BAT file where you could...
	echo CONSOLE MODE > c:\console.txt
	start /w compiled.exe
	del c:\console.txt
And WinBatch could do a FileExist on the console.txt file to see if maybe it was launched from the BAT file.
Article ID:   W12890
Filename:   How to Detect if a WBT was Launched from DOS Console.txt
File Created: 1999:04:15:16:50:20
Last Updated: 1999:04:15:16:50:20