Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add some shell actions to execute some apps. These apps require some environment set from complex batch files.
That is, my action should call:


The problem is that SetPath.bat opends up cmd.exe and sets environment AND stays inside cmd.exe But I need to set that environment and then execute an app. On top of that the app is a gui app, so it would be nice to avoid showing up console when I run the environment batch file (I can use hidcon for that).

The gui app is cygwin shell (mintty) and at login there I also need to add some action :) but it's not a big deal.

I've seen similar stuff done with vbs, but I can't recall where.

share|improve this question
up vote 2 down vote accepted

Normally, when you run a batch-file from another batch-file, control is permanently transferred to the second one. If you want it to run and then return, use the call command.

Normally, when you run a command in a batch-file, the batch-file waits for the command to finish before moving to the next line. To make it continue to the next line without waiting, use the start command.

So you need to change your .bat file to read:

call  c:\xxx\setpath.bat
start c:\yyy\startapp.exe

It calls setpath which runs, then it returns and starts startapp, then continues to the next line, which in this case is the end-of-file so the batch-file ends and the console window closes, leaving the GUI program runnning.

share|improve this answer
Thanks. Actually there was no problem and I thought that solution should be something similar to include ('.') operator in bash to prevent setpath.bat for getting stuck, but it was simply a shortcut that used `cmd /k' and I simply removed that part. The only issue remains is the hidcon part. – Pavel Jul 26 '12 at 2:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .