Page 1 of 1

undefined variable for return variable in Run Program

Posted: Fri Feb 03, 2012 9:39 am
by ttcn2k4
Hi:

I assigned a Run Program to get the result into a variable, then make a compare after that. However, it issues an undefined variable error during compiling.

Run Program sc.exe create "CFS" start= auto binPath= "$TARGETDIR$\Service.exe" obj= $USERDOMAIN$\CFS password= $PWRINPUT$ (WAIT, get result into variable CFSRESULT)
if Variable CFSRESULT Equals 0
MessageBox: INFORMATION, Inside: $CFSRESULT$
end

Is there anything that I should do to fix it?

Also, the $CFSRESULT$ always returns the same value (1) no matter the password is wrong or right and the service is created. When I test the "sc.exe create" command at MS-DOS, it won't be able to create a service if the password is wrong. Anyone has any idea?

Thanks
Nhan

Re: undefined variable for return variable in Run Program

Posted: Fri Feb 03, 2012 8:13 pm
by giaviv
Hi,

What is the error level you get when you run sc.exe in cmd? Try typing echo %errorlevel% - is it 1?

Re: undefined variable for return variable in Run Program

Posted: Mon Feb 06, 2012 11:54 am
by ttcn2k4
I caught 2 cases of the return value 0 or 1057. However, the %errorlevel% always 0. Well, at least I can have 2 different values to compare now. Thus, my main question is about the variable. When I have the comparison "if Variable CFSRESULT Equals 0", I got undefined variable for CFSRESULT at compiling.

I have tried with "if Variable CFSRESULT Equals 1", same error message. Only the "MessageBox: INFORMATION, Outside: $CFSRESULT$" (without if command) is fine.

Thanks
Nhan

Re: undefined variable for return variable in Run Program

Posted: Mon Feb 06, 2012 8:55 pm
by giaviv
Hi,

Try defining the variable first - just enter at the top of your script:

Code: Select all

Set Variable CFRESULT to 

Re: undefined variable for return variable in Run Program

Posted: Mon Feb 06, 2012 8:55 pm
by giaviv
Hi,

Try defining the variable first - just enter at the top of your script:

Code: Select all

Set Variable CFRESULT to 

Re: undefined variable for return variable in Run Program

Posted: Thu Feb 09, 2012 11:47 am
by ttcn2k4
it works.

Thanks
Nhan

Re: undefined variable for return variable in Run Program

Posted: Thu Feb 09, 2012 11:55 pm
by giaviv
No problem!