Page 1 of 1

disallow multiple instances still allows multiple instances

Posted: Tue Nov 06, 2007 2:15 am
by brodie
I have "allow multiple instances" disabled so that all files open in the same instance. When I run the following command (to open all .php files in the current tree), it issues very quickly many "textpad file.php" calls.

FOR /F "tokens=*" %G IN ('DIR /B /S *.php') DO textpad "%G"

If Textpad is already running, they will all open in the same instance. If it is not already running, then it will start multiple instances. This appears to be a problem in the startup code - there is no mutex or similar strategy used to ensure that only a single instance is being started.

Regards,
Brodie

Posted: Wed Nov 07, 2007 6:29 pm
by Drxenos
How about:

SET ALL=
FOR /F "tokens=*" %%G IN ('DIR /B /S *.php') DO SET ALL=!ALL! %%G
textpad %ALL%


make sure to use "setlocal enabledelayedexpansion"

Posted: Wed Nov 07, 2007 10:54 pm
by MudGuard
How about:

SET ALL=
FOR /F "tokens=*" %%G IN ('DIR /B /S *.php') DO SET ALL=!ALL! %%G
textpad %ALL%


make sure to use "setlocal enabledelayedexpansion"
This only works for a smaller number of files, as the length of the command line is limited - the original version has no limit.


Just an idea:
Use
textpad
sleep 1000
FOR /F "tokens=*" %G IN ('DIR /B /S *.php') DO textpad "%G"

Choose a time for sleep long enough for the textpad instance to start up.
(if your system does not have a sleep, you can easily find one with google - make sure to select an appropriate time - some sleep utilities use seconds, some milliseconds).