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

Script help

I wrote a script to stop a process from running then call uninstall on my program but it does not appear to be working. I have put in message boxes to check that it is hitting inside the if statements and it seems to be executing all of the code....but nothing gets shut down or uninstalled.

exePath = "";
exePath = INSTALLDIR ^ "MyApp.exe";
LongPathToQuote(exePath,FALSE);

// check if the file is in use
if (Is (FILE_EXISTS, exePath) = TRUE) then

hWnd = FindWindow("", "My App");
if (hWnd != 0) then
PostMessage(hWnd, WM_QUIT, 0, 0);
endif;

// if the file exists call uninstall on it
LaunchAppAndWait("msiexec.exe","/quiet /uninstall {MyProductCode}",WAIT);
endif;


Any help is greatly appreciated, Thank you.
Labels (1)
0 Kudos
(4) Replies
dan_galender
Level 10

Is this a Basic MSI project with your code in an InstallScript Custom Action?

If so, Where is this code sequenced? Have you tried generating a log file?

In either case, you might also capture the return code from the LaunchAppAndWait call and display it.

One other point: Looking to see if a file exists is different from seeing if the file is in use. To see if the file is in use, look at the Is function with the FILE_LOCKED parameter.
0 Kudos
Flaminchiten
Level 3

Yes it is a basic MSI and the custom action is sequenced right after this event 'SetARPINSTALLLOCATION'

I will capture the return from the LaunchAppAndWait then display it to get a better feel for what is going on.

I was using the Is FILE_LOCKED then calling EXIT on exePath, but it was not working and found the code I am using now on the forums here.
0 Kudos
Flaminchiten
Level 3

I added this section of code to replace the FindWindow stuff, it says it completes successfully but the program does not exit.


if (Is (FILE_LOCKED, exePath)) then
nreturn = Is(EXIT, "My App");
MessageBox("EXIT = " + FormatMessage(nreturn), INFORMATION);
endif;
0 Kudos
dan_galender
Level 10

I don't see EXIT as a valid parameter to pass to the Is function. Most likely that's the problem with the return code.
0 Kudos