Add paths to environsment and launch and app

1

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:

c:\xxx\SetPath.bat
c:\yyy\startApp.exe

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.

Pavel P

Posted 2012-07-26T02:07:27.933

Reputation: 1 558

Answers

2

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.

Synetech

Posted 2012-07-26T02:07:27.933

Reputation: 63 242

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 P – 2012-07-26T02:34:58.617