cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mikegillow
Level 5

How to see all command line switches used when setup.exe started?

I have an InstallScript MSI project. I know how to use /z to pass info to the CMDLINE InstallScript variable. What I'm looking for, though, is to access the entire set of arguments used when setup.exe was called. My problem starts with uninstalling from ARP - in my OnBegin I check for certain processes and if they are running they need to be shut down and the system rebooted before the uninstall can try again. I'm trying to set up RunOnce to restart the uninstall after reboot and need to pass it everything from the original commandline used by the ARP call. I know I'm probably missing something obvious, but at the moment I'm coming up empty.

Can anyone enlighten me? Thanks.
Labels (1)
0 Kudos
(5) Replies
rguggisberg
Level 13

Try using the environment variable %CMDCMDLINE%. It returns the exact command line used to start the current cmd.exe.
0 Kudos
mikegillow
Level 5

I tried:
	if (GetEnvVar("CMDCMDLINE", svTemp)<0) then
MessageBox("Unable to find env var CMDCMDLINE", INFORMATION);
else
MessageBox("CMDCMDLINE : "+svTemp+":", INFORMATION);
endif;

and I get the "unable to find" message. So it appears that the CMDCMDLINE env var does not exist when the script is running. I'm guessing that is why the /z parameter exists to pass info to CMDLINE - but that doesn't help me since I'm trying to replicate the entire command line used to start setup.exe.
0 Kudos
RobertDickau
Flexera Alumni

I haven't tried it, but perhaps the GetCommandLine API function? Something like:
prototype STRING Kernel32.GetCommandLineA( );

function OnBegin( )
begin
MessageBox(GetCommandLineA( ), INFORMATION);
end;
0 Kudos
mikegillow
Level 5

Thanks - looks like that should do it.
0 Kudos
pbsdis
Level 6

I mistakenly put my post in 'IS2010 Express', what I want to know is how to get the commandline information in Basic MSI project (the commandline executs setup.exe).


Thanks
0 Kudos