thelliez
15th November 2005 20:50 UTC
ExecDos parameters syntax?
How does one pass parameters to a command using ExecDos.
The following does not work:
ExecDos::Exec '"sc" config "Apache Tomcat 4.1" obj= .\$R8 password= $R6)' "" ""
It seems that ExecDos is great at managing stdin and stdout, but what about parameters?
Thanks,
Thierry
Takhir
16th November 2005 09:12 UTC
It not manages command line parameters. ExeDos uses CreateProcess() with first plug-in parameter as lpCommandLine parameter for this call. In your case this is
"sc" config "Apache Tomcat 4.1" obj= .\$R8 password= $R6)
where sc is module to execute and other strings are parameters.
MSDN: "First quoted string indicates where the filename ends and the arguments begin." I see 6 or more (argc, argv) parameters in your command line (more if $R8 or $R6 include spaces). Are you sure that spaces after '=' required?
And again from MSDN: "If the process to be created is an MS-DOS - based or 16-bit Windows-based application, lpCommandLine should be a full command line in which the first element is the application name. Because this also works well for Win32-based applications, it is the most robust way to set lpCommandLine." So better use full path.
BTW your parameters differ from sc.exe 'usage' I see on my WinXP. Is '$R8)' correct parameter? And you can use log file to check process output (last plug-in parameter).
thelliez
16th November 2005 17:11 UTC
Thanks for your answer.
My initial string was not totally correct. I forgot one '(', and below I made the var names more obious:
("sc" config "Apache Tomcat 4.1" obj= .\$USER password= $PASSWORD)
Yes the spaces before obj and password are required. I know, that's a word syntax... but there are plenty of examples on the web doing that. I was able to validate that from the cmd command line.
The parenthesis were added as an attempt to work with ExecDos (I also tried nsExec). The multiple double quotes could be an issue. The parenthesis work fine under MS-DOS and Windwos 2003.
From your message I gather that the following should work:
ExecDos::Exec '("sc" config "Apache Tomcat 4.1" obj= .\$USER password= $PASSWORD)' "" ""
But it did not...
Thierry
Takhir
16th November 2005 18:21 UTC
I changed vars to strings for my test only, and both in the black console window (with and without () )
>"sc" config "Apache Tomcat 4.1" obj= .\USER password= PASSWORD
and in the ExecDos stdout.log
ExecDos::Exec '"$SYSDIR\sc.exe" config "Apache Tomcat 4.1" obj= .\USER password= PASSWORD' "" "$EXEDIR\stdout.log"
Pop $1 ; bat exit code
MessageBox MB_OK "Exit code=$1"
I had the same result:
[SC] OpenService FAILED 1060:
This means that sc.exe starts. And you can try to understand the problem with parameters using stdout. BTW my XP offers another sc command line, but, probably <server> parameter is optional:
sc <server> config [service name] <option1> <option2>...
Takhir
16th November 2005 18:39 UTC
This line successfully executes sc (not your command, but I can test this on my home PC)
ExecDos::Exec /TIMEOUT=3000 '"$SYSDIR\sc.exe" qc dnscache 1024' "" "$EXEDIR\stdout.log"
[SC] GetServiceConfig SUCCESS
...