Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
4.33/5 (4 votes)
See more:
If an application which is configured for single-instance operation is run from a batch file, is there any nice way to control how long the batch file waits and what error code will be returned to it? The best approach I can figure would be to have a pair of programs: a windowed application that runs single-instance, and a console application that runs multi-instance. When run, the console application would invoke the single-instance application with a parameter containing something like a TCP socket. The single-instance application could then pass back the desired error code as well as any messages it would like the console application to display.

My intended use would be that the batch files do operations which may only be done one at a time, and to have the single-instance application sequence the operations, and then remain up after the operations are complete to show their status.

My target platform is .net 2.0. Any ideas?
Posted

Hi,

a single-instance app never really is single-instance. At best the second, third or whatever instance gets launched, detects it isn't number one, and exits again, hopefully after passing its work to the first instance, maybe by sending its command line through a pipe.

how about you make the "single-instance" such that it:
- detects it isn't the first;
- sends the job to the number one instance;
- instead of exiting right away, waits for completion.

Doing it that way your batch files don't have to be aware, they would always seem to be talking to the single-instance app.

BTW: obviously you can use the Main() method's return value as the batch/DOS exit code.

:)

 
Share this answer
 
MoNUmy zwtbxuwmitra, [url=http://cbjuxwnxmvsy.com/]cbjuxwnxmvsy[/url], [link=http://tucrbzulnook.com/]tucrbzulnook[/link], http://zzzelknyktmt.com/
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900