One would suspect that since VS supports - or +new at command line startup (to distinguish between cases where an existing instance of VS.EXE should be used or a new instance created) then there may be an elegant way to detect this situation in a macro. You could search the supplied macro code to see if you can find a way. However, an inelegant technique that works in Windows XP is as follows:
1. You must have TaskList.EXE in your path... normally this is available only on Windows XP professional, but it can be downloaded for the home version of XP.
2. A batch file similar to the following (e.g. PROCCOUNT.BAT) should be saved in a directory in the the PATH:
@ if exist $out del $out
@ tasklist /FO csv /FI "IMAGENAME eq %1" /nh 1>$out 2>$err
@ set $acc=
@ for /F %%i in ($out) do @set /a $acc=$acc+1
@ if exist $out del $out
@ exit /b %$acc%
3. A macro can be created similar to the following that will run PROCCOUNT and check for instances of running processes by their name: (Note the special logic to adjust the count of CMD.EXE processes, if that count is necessary, since shell() introduces a new instance of cmd.exe when the count is taken.)
_command proccount() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_macro('R',1);
cmdstring = "proccount ":+arg(1):+'&exit /b %$acc%';
count = shell(cmdstring,"Q");
if (stricmp(arg(1),"cmd.exe") == 0)
{
count--;
}
if (count >= 2)
{
messageNwait(count " instances of "arg(1)" are running");
}
else if (count == 1)
{
messageNwait("only one instance of "arg(1)" is running");
}
else
{
messageNwait("there are no instances of "arg(1)" running");
}
}
4. To test the above macro, run PROCCOUNT VS.EXE from the command line in Vslick.