Jump to content

Uninstall msiexec with administrative privillage using Autoit


donarm
 Share

Recommended Posts

Hi,

Anyone can help me to write a simple script to uninstall software package using msiexec with administrative privillage? I need this script can uninstall more than 1 software with silent mode. I've tried to write the script below but this script it seem not working.

; Fill in the username and password appropriate for your system.

Local $sUserName = "username"

Local $sPassword = "password"

Local $sDomain = "domain"

Local $sProgram1 = "msiexec /x {Product Code} /q /norestart"

Local $sProgram2 = "msiexec /x {Product Code} /q /norestart"

; Run a command prompt as the other user.

RunAs($sUserName, $sPassword, $sDomain, 0, $sProgram1)

RunAs($sUserName, $sPassword, $sDomain, 0, $sProgram2)

Thanks,

Don

Link to comment
Share on other sites

Your RunAs command is formatted incorrectly

RunAs ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag ]]] )

Your domain and password variables are reversed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Your RunAs command is formatted incorrectly

RunAs ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag ]]] )
He's probably going to think the brackets ( [ ] ) need to be in there like how I thought when I was starting off.
Link to comment
Share on other sites

Copy/paste from the help file, didn't think about the brackets.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Local $sUserName = @UserName
Local $sPassword = "password"
Local $sDomain = @ComputerName
Local $sProgram1 = @ComSpec & ' /c "msiexec /x {Product Code} /q /norestart"'
Local $sProgram2 = @ComSpec & ' /c "msiexec /x {Product Code} /q /norestart"'
RunAs($sUserName, $sDomain, $sPassword, 0,  $sProgram1)
RunAs($sUserName, $sDomain, $sPassword, 0,  $sProgram2)

You wan't some coffee with that?

Link to comment
Share on other sites

Local $sUserName = @UserName
Local $sPassword = "password"
Local $sDomain = @ComputerName
Local $sProgram1 = @ComSpec & ' /c "msiexec /x {Product Code} /q /norestart"'
Local $sProgram2 = @ComSpec & ' /c "msiexec /x {Product Code} /q /norestart"'
RunAs($sUserName, $sDomain, $sPassword, 0, $sProgram1)
RunAs($sUserName, $sDomain, $sPassword, 0, $sProgram2)

You wan't some coffee with that?

I've tried this command but only 1 software successfully uninstall and another one still inside on the user computer. This problem occurs because of the embargoevents.exe application running while the uninstallation still in progress. This file belongs to product EmbargoEvents.exe and was developed by company Scriptlogic Software Corporation. So how i want to close or disable this application from running to make my uninstall successfull?

Edited by donarm
Link to comment
Share on other sites

You probably can't uninstall 2 programs at the same time anyways, so you should probably be using RunAsWait instead of RunAs. RunAsWait will pause the script until the program has closed.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi guys,

I got it working perfectly!! After i'm added the RunAsWait on my command instead of RunAs i still have problem to uninstall this product. This problem occurs because of my account not strong enough to perform this task on the user computer. I'm not sure why my account can't perform this task even it already member of domain admin and enterprise admin.

Thanks everyone for the help.. :)

; Fill in the username and password appropriate for your system.
Local $sUserName = "username"
Local $sPassword = "password"
Local $sDomain = "domain"
Local $sProgram1 = "msiexec /x {Product Code} /q /norestart"
Local $sProgram2 = "msiexec /x {Product Code} /q /norestart"

; Run a command prompt as the other user.
RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram1)
RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram2)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...