cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Ivan_mysammy
Level 4

my installscript custom action only works in debug mode

the purpose of my installscript is to delete application root folder and all its contents. when uninstall the application:

If run my insytaller in InstallShield IDE by enter "F5", following installscript works and return messagebox showing "** was deleted";
but if i run the compiled **.msi file for uninstall, messagebox return "Unable to delete directory".

It seems very weird.

Developing environment:
OS: windows server 2008 R2
InstallShield version: 2011
Installscript code:


function Fn_DeleteDir(hMSI)
STRING strInstallDir;
NUMBER nSize;
begin
nSize = 256;
MsiGetProperty(hMSI,"INSTALLDIR",strInstallDir,nSize);
if (DeleteDir (strInstallDir, ALLCONTENTS) = 0) then
// Report success.
MessageBox (strInstallDir + " was deleted.", INFORMATION);
else
MessageBox ("Unable to delete directory.", SEVERE);
endif;
end;

another thread report a similar issue:
http://community.flexerasoftware.com/showthread.php?t=58380
Labels (1)
0 Kudos
(4) Replies
Ivan_mysammy
Level 4

More clues:

above installscript works when uninstall through commend line execution with administrater previllage.
above installscript works on 32bit installer at 32bit machine.

So I probably find the reason but not the solution.
the UAC on windows NT after vista stops my installscript custom action remove files, so i need to surpass UAC or programaticly assign administrator previllage to the installer.
BTW, i dont want additional files add to the installer like a XML manifest.

Now it looks like this is a common issue for custom action deleting files on 64 bit windows.
the reason that i dont use "removefile table" is the files to be removed has random names, which cannot be defined in advance.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

Any custom actions that modify the system need to be sequenced somewhere between InstallInitialize and InstallFinalize in the install execute sequence. In addition, the "In-Script Execution" setting needs to be set to "Deferred in System Context". This will run the custom action with elevated privileges in most normal cases. If the action is not configured this way, and the action attempts to modify any per-machine resources, it will fail on Windows Vista or newer when UAC is enabled.
0 Kudos
Ivan_mysammy
Level 4

This problem resolved, let me finish the thread.

Simply speaking, I should select "deffered excution in system context" instead of "immediate execution" for my deletedir custom action. In addition, create another immediate execution custom action to pass INSTALLDIR property value to "CustomAction Data", because only limited properties can be access during deffered excution. Thus, UAC message popup when installscript is running, then installscript works.

the reason of why it works in debug way is you already have administrator previllage running InstallShield, so the UAC was surpassed.

I guess this is the most common way to delete install directory and all its contents after uninstall if there are lots of files not generated by installer. Although the method is simple, it still took me few days to find it.

Hope it helps.
0 Kudos
Ivan_mysammy
Level 4

joshstechnij wrote:
Any custom actions that modify the system need to be sequenced somewhere between InstallInitialize and InstallFinalize in the install execute sequence. In addition, the "In-Script Execution" setting needs to be set to "Deferred in System Context". This will run the custom action with elevated privileges in most normal cases. If the action is not configured this way, and the action attempts to modify any per-machine resources, it will fail on Windows Vista or newer when UAC is enabled.


Thanks for answering my question. You are right! I just found this reason. I lacked knowledge when posted this thread
0 Kudos