cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rajeevshukla
Level 3

Parameter not passed to cmd.exe in LaunchAppAndWait

I am working with a Basic MSI project and I am trying to schedule a windows task through the installer. I am using the DOS "schtasks" command. Here is the call that I am using for the same:

LaunchAppAndWait ( "cmd.exe", "schtasks /Create /SC WEEKLY /D "+svTaskDay+" /ST "+svTaskHr+":"+svTaskMin+":00 /TN \"Update XPS\" /TR "+szProgram, WAIT);

svTaskDay is a variable that collects the day from the user, scTaskHr and svTaskMin have the time in hour and min as entered by the user. szProgram has the path to the file that I want to execute.
While this command works fine from the command prompt, it is not working from InstallShield. The command prompt is invoked but the parameters specified are not passed. Any thoughts on this is welcome.
I am building installer for Windows XP and Windows 2003.
Labels (1)
0 Kudos
(4) Replies
vinodn1
Level 4

Try storing the parameter in a string variable before the LaunchAppAndWait call. Also try printing out the string in a MessageBox and verify the quotes are as expected. If the quotes are not correct, use the LongPathToQuote function.

Also the "/" symbol would ignore the next character....check if that is the case....
0 Kudos
RobertDickau
Flexera Alumni

It probably doesn't matter, but you should also be able to launch schtasks.exe directly, instead of going through cmd.exe...
0 Kudos
rajeevshukla
Level 3

I have tried saving the parameter in a string and printing the value also. The command is perfect. Somehow the parameter is not getting passed. Even a simple dir command is not passed.

I cannot execute schtasks directly. With cmd.exe the command prompt appears, but if I try running schtasks directly, nothing appears
0 Kudos
packagechief
Level 5

rajeevshukla wrote:
I have tried saving the parameter in a string and printing the value also. The command is perfect. Somehow the parameter is not getting passed. Even a simple dir command is not passed.

I cannot execute schtasks directly. With cmd.exe the command prompt appears, but if I try running schtasks directly, nothing appears


Do you have tried the following:

"cmd.exe /c", "schtasks /Create /SC WEEKLY /D "+svTaskDay+" /ST "+svTaskHr+":"+svTaskMin+":00 /TN \"Update XPS\" /TR "+szProgram, WAIT);

this woud call the program within a cmd interpreter session and then it shoud work
if not there is also the possibility to handle the whole with the help of a custom action

see screenshot attached of an example how to configure the custom action

as you can see the command (schtasks in your case) is beetween two brackets this method is very handy
to call system specific command within the cmd interpreter while the setup process is running

and don't forget to set the condition "Not Installed" or the Custom Action will also be called while uninstalling the app!
0 Kudos