0

I am trying to uninstall a program from my visual studio project but that seems to requiere me to run vs as an admin....so i tried doing this from the cmd to debug it .

I have managed to uninstall a msi setup project installation with this command from cmd :

msiexec /x {3A40307D-6DF2-4412-842F-B1D848043367} /quiet , but that only works when i start cmd as an admin, without admin rights it wont uninstall. What am i doing wrong and is there another approach to get the result I want?

I want to be able to silent uninstall an application without having to ask the user to login as an admin.

Edit:

This is the result from the log :

Error 1001. Error 1001. Unable to delete file C:\ProgramData\XXX.InstallState. DEBUG: Error 2769: Custom Action _F6174138_B428_4AB6_9FEF_C4DD7A69BDC0.uninstall did not close 1 MSIHANDLEs. The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2769. The arguments are: _F6174138_B428_4AB6_9FEF_C4DD7A69BDC0.uninstall, 1, CustomAction _F6174138_B428_4AB6_9FEF_C4DD7A69BDC0.uninstall returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox) Action ended 17:54:40: InstallExecute. Return value 3. Action ended 17:54:40: INSTALL. Return value 3. MSI (s) (F0:3C) [17:54:40:355]: Product: XXX -- Removal failed.

syncis
  • 1,395
  • 4
  • 25
  • 43

2 Answers2

1

It appears you have several options here. All of them require creating an msi that doesn't require Admin privileges from the start. If the msi requires them from the start (eg, you have no control over the creation of the msi), there is no way around it. It all depends on what files are being edited as to whether or not admin rights are really required. Check out this answer: How can I create a windows installer MSI that does not require admin access

Community
  • 1
  • 1
Pete Garafano
  • 4,863
  • 1
  • 23
  • 40
1

That error from the log file indicates that a custom action is crashing. You'll want to investigate the root cause of that issue. My guess is that the custom action requires elevation (admin privileges) to work correctly but is not marked deferred (i.e. runs during the part when the MSI is elevated).

If you launch the uninstall of the MSI from Add/Remove Programs (Programs and Features) then you should not be prompted for elevated credentials. Thus the root issue probably is this custom action.

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • You are right, it does requiere administrative rights to work and I am using custom actions to create shortcuts for the application after install. How to solve this? Remove the custom actions or is there any option to make it not requiere admin rights? – syncis Mar 18 '13 at 12:53
  • Why are you creating shortcuts via a custom action? The Windows Installer supports creating shortcuts. Other than that, requiring elevation is purely a function of your installation's requirements. If you are installing to perMachine locations, you'll require elevation. Install to only perUser locations and you can avoid it. – Rob Mensching Mar 18 '13 at 14:51
  • In the setup i have an option for the user to choose wether to create shortcuts or not create shortcuts, and i dont know how i should make the installer do that depending on what the user choose without custom actions. If you have any idea, do tell please. – syncis Mar 18 '13 at 22:53
  • Condition your Components. – Rob Mensching Mar 19 '13 at 02:24
  • Sorry i dont understand what you really mean by condition your components =/ – syncis Mar 19 '13 at 08:15
  • Add a Condition element under the Component element. – Rob Mensching Mar 19 '13 at 14:11
  • Add a condition to create a shortcut ? I have never seen a function in windows installer where you can create a shortcut without making custom actions ... – syncis Mar 20 '13 at 12:32