We help IT Professionals succeed at work.

Batch file assistance

vwchristopher
on
Medium Priority
422 Views
Last Modified: 2012-08-13
I need to create a batch file which starts a windows program and then goes on.  So far I have what is printed below.  When it gets to uniprint.exe, it loads uniprint, but then stops, so I don't see the pause and it doesn't run remote access.  What am I doing wrong?

C:
cd \Program Files\UniPrint\Client
UniPrint.exe
pause
c:\windows\system32\mstsc.exe
Comment
Watch Question

vwchristopherDirector

Author

Commented:
More info - I'm trying to run a program to enable remote printing then run remote access.  I find that if I close uniprint the batch file continues.
Test your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016
Commented:
Try using START to initiate the program, it allows options that can load the program and continue the BAT file without waiting for it to end.  So try something like:

cd /D C:\Program Files\UniPrint\Client
start "" "UniPrint.exe"
pause
c:\windows\system32\mstsc.exe

Open in new window


~bp
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Also notice that the CD /D option allows the drive to be changed if needed, so no need for the two commands to do that, can be done with one.

Also, you might be able to get away with this, but it depends on the program you are running.

start "" "C:\Program Files\UniPrint\Client\UniPrint.exe"
pause
c:\windows\system32\mstsc.exe

Open in new window

~bp

Commented:
Problem is batch is linear, each command waits until what it does is completed.

You can get around this like this:

cmd.exe /c UniPrint.exe

It will launch a new cmd, execute the command and exit the new cmd when the comman completes. All while your main script continues executing what was below that line.
chris_martin62Desktop Systems Analyst
CERTIFIED EXPERT

Commented:
can i ask why you have the pause? have you tried to take it out and see if it runs.
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
And one more small point to clarify, the syntax below may look a little funny, since there is a "" for the first parm, which can be optional for this command.  But there is a small "bug" in the start command, which is if you quote the program you want to start, then you have to include the first positional parameter, the window title.  So the safest way is often to just include an empty first parm so that if the program to be started has spaces in it's path and needs to be quoted, then all works well.

start "" "C:\Program Files\UniPrint\Client\UniPrint.exe"


~bp
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
I'm pretty sure the PAUSE was just for debugging purposes...

~p
vwchristopherDirector

Author

Commented:
The pause was for debugging!

The start command was the one that resolved the issue. cmd.exe did not resolve it.

Thanks for all your help!
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Welcome, glad that solved it.

~bp

Explore More ContentExplore courses, solutions, and other research materials related to this topic.