This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- my installscript custom action only works in debug mode
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 01, 2010
02:37 PM
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
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
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 01, 2010
04:49 PM
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.
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 05, 2010
12:52 PM
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 05, 2010
01:03 PM
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.
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 05, 2010
01:07 PM
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
![](/skins/images/8CE4FAD0DE6F3A6F9D0567434D2D2DAE/responsive_peak/images/icon_anonymous_message.png)