|
Answer» Hello, i have this script not running ok, it depends how it is launched.
IF "%RUNNING%"=="E" ECHO Program is already running&SLEEP 1&EXIT SETX RUNNING E -M
ECHO now any other program instances will be revoked PAUSE
REM program tasks
SETX RUNNING K -M EXIT
This script doesn't let the program (REM program tasks) launch a second time. There are programs that work only a single instance at a time, otherwise bad things happen.
Launched from explorer it is working FINE, launched as a parameter from another program, (using another program), it won't work anymore, i'm wondering why.
The script works ok until i launch it using the main surveillance program, by example WebCam Monitor http://www.deskshare.com/wcm.aspx Then it doesn't care anymore of the %RUNNING% variable.
It can be seen at the PAUSE that %RUNNING% is not replaced adequately. Let echo on to see the error.
WebCam Monitor has an easy way to test this, without having a camera attached. The way is to press Test Selected Alerts (more times) after have checked Launch Program and Configure it to launch the above script.
When we take the case the script is launched from WebCam Monitor http://www.deskshare.com/wcm.aspx Run it without @echo off and you'll see in the IF statement what is replacing RUNNING variable, you'll see that during the script, RUNNING doesn't take the adequate value, i think it will be not defined, also the same time if you look in system properties/advanced/env var, you'll find the correct value for it.
link for SETX: http://www.deskshare.com/wcm.aspx http://support.microsoft.com/kb/927229
link for SLEEP: http://www.petri.co.il/download_free_reskit_tools.htm http://www.microsoft.com/downloads/details.aspx?displaylang=en&familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd
Ask me anything you want please, if confused.I'm not sure I understand the ISSUE.
What OS are you running?
It sounds like sometimes the environment variable RUNNING does not have the right value? What value should it have, and what value does it have when it is not working CORRECTLY?
What is the syntax used when it is launched from explorer? And the syntax used when launched from the other program?It sounds like sometimes the environment variable RUNNING does not have the right value?
>>>Yes, it's like the script doesn't recognize RUNNING as being defined or as being the adequate value, whereas w2k pro in its system prop/advanced... sees RUNNING correctly.
What value should it have, and what value does it have when it is not working correctly?
>>>first time the script is runned, RUNNING will not be defined at all, will not be "E" or will be "K". So, it will skip the line: IF "%RUNNING%"=="E" ECHO Program is already running&SLEEP 1&EXIT and will set RUNNING "E", then it will PAUSE. This time if launched again the same script, it will see RUNNING being "E" and will EXIT. This is happening until the first script launched will end, when it will reset RUNNING to "K". (Instead of PAUSE line will be my program, so it won't run a second instance of it)
Now i'll say what value RUNNING has when it is not working ok. It has exactly the value before WebCam Monitor launch, usually it is "K" if script runned once. WebCam Monitor will keep the value "K" on and on, for the script, otherwise windows shows its correct value.
What is the syntax used when it is launched from explorer?
>>>Just double click on it.
And the syntax used when launched from the other program?
>>>WebCam Monitor has a configure window for Launch Program: -specify program - i passed just the BATCH without any parameter -parameters for the program -start in folder - i passed the script folder
|