cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
selwynreynolds
Level 7

LaunchAppandWaitError

I have an InstallShield 2009 InstallScript project. I have the following code to launch an external .msi program. It does not work. When I call GetLastError it returns 0.

When I run the szProgram line ( msiexe /a "c:\temp\setup.msi" )in a command window it works fine.

I've tried it with the LongPathToQuote line and without it - same result.

strDir = "C:\\temp";
szProgram = "msiexe /a \''" + strDir + "\\setup.msi\"";
LongPathToQuote(szProgram, TRUE);
if(LaunchAppAndWait(szProgram, "", LAAW_OPTION_USE_SHELLEXECUTE | nWait) < 0) then
nErrorCode = GetLastError();
NumToStr(strError, nErrorCode);
MessageBox(strError, WARNING);
else
MessageBoxs("success", OK);
endif;

Any ideas why this doesn't work from within an InstallScript project?

Thanks. :confused:
Labels (1)
0 Kudos
(6) Replies
RobertDickau
Flexera Alumni

A couple of things: perhaps use WINSYSDIR^"msiexec.exe" as the first argument to LaunchAppAndWait, and "/i ...Productname.msi" as the second? (Was the "/a" switch---which performs an administrative installation, which isn't the same as a "real" installation---intentional?)

Otherwise, what is or isn't happening?
0 Kudos
selwynreynolds
Level 7

Hi - thanks for your suggestions, unfortunately they did not work (used WINSYSDIR and /i). The reason I am using "/a" as the second argurment is due to a post I found online about running an msi package on Vista. My InstallScript project runs some 3rd party self-extracting zip files and then a windows installer that someone else wrote. The windows installer throws an error when run on Vista (runs fine on XP) when the exe calls the msi. The post suggested using msiexec to run the msi and said the /a would be necessary due to UAC on Vista.

So, what is happening is, I get the MessageBox that tells me GetLastError() returned 0 and the install goes to my next line of. Maybe I am using GetLastError() incorrectly?

At the top of my setup.rul file I have
prototype number Kernel32.GetLastError()

And then just call it with nErrorCode = GetLastError().

I am testing the call on an XP machine before I move the install to the Vista machine. Typing the command in a command window works on Vista just as it does on XP.

Thanks so much.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

To get the launch result error code for LaunchApplication/LaunchAppAndWait, use LAAW_PARAMETERS.nLaunchResult. This should provide the error code indicating why CreateProcess failed to launch msiexec.exe. (Using GetLastError doesn't work as expected because there are other calls to Win32 after CreateProcess is called that overwrite the last error value, which is why InstallScript sets the nLaunchResult value).
0 Kudos
selwynreynolds
Level 7

Hello again,

I am not checking the laaw_parameters.nLaunchResult error and it is returning a 2. I've looked around and have yet to find out what the 2 indicates.

Where can I look for descriptions of the numeric error codes?

Thanks again.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The error codes set in the launch result are Windows system error codes. Error code 2 is "The system cannot find the file specified."
0 Kudos
selwynreynolds
Level 7

OK thank you! That explains that problem.
0 Kudos