Launch EXE with working directory custom action privs problem - Advanced Installer Community
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Launch EXE with working directory custom action privs problem

PROBLEM: I have a “Launch EXE with working folder” custom action for uninstall. When an admin user goes to control panel | Programs and Features and tries to uninstall my application, the uninstall tries to run my exe, but fails with Access Denied. I grabbed a procmon trace when this occurs and msiexec is trying to execute my exe but fails with ACCESS DENIED.

DETAILS:
In my custom action originally the “Execution Time” setting was “Immediately”, and thus the “Execution Options” setting for “Run under the LocalSystem account with full privileges (no impersonation)” was grayed out. So, impersonation was expected I guess. This caused the uninstaller to fail with access denied.

But, following the suggestions I have seen for other folks with this problem I changed the “Execution Time” to “When the system is being modified (deferred)” and selected the “Run under the LocalSystem account with full privileges (no impersonation)” option under “Execution Options”

“Wait for custom action to finish before proceeding” was checked under “Execution Options” in both cases. Using these new settings I tried again and captured the uninstall with procmon. Msiexec is still trying to impersonate and still fails with ACCESS DENIED?? I have tried this several times to make sure I have everything set the way I expect.

It would be fine if it tried to elevate, as my user on this machine is an administrator. But, it doesn’t try to elevate or whatever to get past the UAC, and it still impersonates even though I set it not to?

One other point: My custom action for uninstall is in the "Install Execution Stage".

How can I get the installer to stop impersonating or otherwise use the correct privs?

Any help would be appreciated!!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi and welcome to our forums.

Please make sure that the custom action that you want to execute on uninstall is placed above the "Remove Resources" action group, otherwise the file it points to might have been already removed from the machine, so the custom action cannot execute it anymore.

Also, please keep in mind that two MSI-based packages cannot run at the same time, so if the package that you try to uninstall is a Windows Installer package, it will conflict with the main package that executes your custom action.

In this case, you can execute the custom action after the "Finish Execution" action group, uncheck the "Wait for custom action to finish before proceeding" and "Wait for return code at the end of the sequence" options and make sure that the file it tries to launch is still on the machine at that point. Another simpler solution is to use the Product Code to uninstall the other package.

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

Nope, did not help at all. The executable I am trying to execute just uninstalls some drivers and services. This uninstall works fine with this installer if I run it as an already elevated user. The problem is NOT that it cannot find the exe, it tries to run the exe and fails, i have that in a procmon trace (MSFT/SysInternals tool process monitor if you aren't familiar). The procmon shows clearly that the installer is trying to run my executable while impersonating the user that started the uninstall from control panel. I set the option in Advanced Installer to NOT impersonate, so I don't know why it is doing this.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi,

I'm not sure why it still does not work for you. Can you please send us the .AIP (project file) and a verbose log of the uninstallation to support at advancedinstaller dot com, so we can investigate them?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

I sent the requested files via email to your support email.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi,

I looked over your project and I noticed the following issues:
- in the "File path" field of your custom actions you use the "\" character right-after the "APPDIR" and "WindowsVolume" properties, but this is not necessary because the value of those properties ends with that character during the installation. In this case, the "\" character is duplicated and the resulted path will not be valid
- the "deferred" with "no impersonation" options are not set for your uninstall custom action

Can you implement the above suggestions and see if your custom actions work?

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

The additional '\', I believe would be ignored, but I removed it. Also, I think I sent the wrong files last time. I re-ran my test scenario with newly generated installer and made sure all of the files are correct. I also grabbed a procmon trace showing that msiexec.exe is indeed accessing my exe with the wrong privs. I emailed the correct files and a couple of screenshots to the support email.

Any help is appreciated!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi,

In the project that you sent, your uninstall custom action is added after the "Remove Resources" action group, which means that the file it references have already been removed before the execution of that custom action. Please add it before the "Remove Resources" action group and test your package again.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

Actually, as you can see from the image I sent you of the procmon capture, the executable was indeed on disk and NOT deleted. msiexec.exe got an ACCESS_DENIED error, not a FILE_NOT_FOUND error. But, I went ahead and fixed the installer as you suggested, re-ran, got the same result and sent you the updated files via email. The problem IS that the installer is not using the correct privs when trying to access that exe. Why is that?

Thanks!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi,

Does your custom action try to uninstall another package? If so, please keep in mind that two packages cannot run at the same time (main package and the custom action package).

So, in order to uninstall that package, you need to run that custom action after the "Finish Execution" stage and uncheck the "Wait for custom action to finish before proceeding" and "Wait for return code at the end of the sequence" options for it.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

Uhmm, my exe just uninstalls some drivers and services. This same installer works great if I go to uninstall from an elevated command-prompt.

I don't think you are looking at the data I sent you.

I sent a clear screenshot of procmon showing that msiexec.exe was attempting to open my uninst.exe using impersonation while I have "don't impersonate" set in the installer.

Do you get the problem here? msiexec.exe found the uninst.exe and tried to open and execute it but failed with ACCESS_DENIED. Do you know what that means?

It does not mean the exe was not there, it does not mean that the exe is doing anything wrong, it means that the installer is using the wrong privileges when trying to execute the exe.

I am not trying to be rude here, but I need a resolution to this. WHY when I set the settings for Advanced Installer to use Local System privileges and NOT impersonate when running my exe does Advanced Installer persist in NOT using Local System and impersonating the user who initiates the uninstall?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

Hi,

I have looked over the files you sent me many times, but I, somehow, missed that your package is set to run "Per-machine if user is administrator, per-user otherwise" in the "Install Parameters" page. Sorry about that.

This means that when the package is installed per-user, the custom actions will be executed under that user's account as the installer does not have the necessary permissions to executed them under the LocalSystem account. This is the normal behavior.

Indeed, the custom action's options are misleading in this scenario, so we will make an improvement regarding this in a future version of Advanced Installer.

As the installer runs under the user account, it does not have privileges to launch a custom action with higher privileges, so this is the reason why your custom action fails.

As a workaround, you can use a "Launch file" custom action instead, and check the "Run as administrator" option for it, but in this case the UAC will prompt during the installation to request the necessary permissions. Otherwise, you can set your package to be installed only "per machine" as it needs to make per-machine changes (e.g. work with files located under the "Windows" folder).

Just let me know if you have any question.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
bmckenzie
Posts: 15
Joined: Thu Nov 17, 2016 1:08 am

Re: Launch EXE with working directory custom action privs problem

Eusebiu,

Ah, that makes sense. So, I modified to use the "Launch File" custom action for the uninstall and checked the "Run as Admin" box and that does indeed appear to fix my problem!!

Thanks for your time on this, much appreciated!!
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Launch EXE with working directory custom action privs problem

You're welcome. I'm glad you got this working.

Just let us know anytime you encounter a problem.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”