Jump to content

Remove application from add/remove program using Autoit with administrative privilage


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 2 application with silent mode at the same time. I've tried to write the script below but this script it seem not working. The script only successfully uninstall 1 application and another 1 still inside on the user computer. Please help me with this script because i need to push this script to 6000 users.

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"
RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram1)
RunAsWait($sUserName, $sDomain, $sPassword, 0, $sProgram2)

Thanks,

Don

Link to comment
Share on other sites

  • Moderators

Hi, Don. For the sake of simplicity and troubleshooting, I would drop it down to just two lines of code and drop all your vars. Try this, and then post which one errors out, and the exact error you're receiving.

RunAsWait("YourAdminUserName", "Domain", "YourAdminPassword", 0, "msiexec /x {product code} /qb /norestart")

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi, Don. For the sake of simplicity and troubleshooting, I would drop it down to just two lines of code and drop all your vars. Try this, and then post which one errors out, and the exact error you're receiving.

RunAsWait("YourAdminUserName", "Domain", "YourAdminPassword", 0, "msiexec /x {product code} /qb /norestart")

Hi Jlogan,

Thanks for your reply, i have no errors out from the code but still get the same result with the old code which only 1 application uninstall and another 1 still inside user computer. The different between your code and mine is the uninstall wizard popup from the user computer. I want to used silent mode which user don't know that the uninstallation running on their computer.

Thanks.

Link to comment
Share on other sites

  • Moderators

Hi, donarm. For silent mode you would simply replace the /qb switch with /qn. Just out of curiosity, what is the application that isn't uninstalling? Are you sure it is an MSI-based install?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi JLogan,

For your information the application that isn't uninstalling is USB Port Security from ScriptLogic which the application is .exe based install. Are you telling me that the script only effected to the MSI-based install only? because another installer that successfully uninstall is MSI-based.

Link to comment
Share on other sites

  • Moderators

Hi, donarm. If the application is not an MSI based install, calling msiexec will not work. The best thing to do is look in the registry at the uninstall string. This is located at HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall. Under the Uninstall key, look for your product ID and then take a look at the uninstall string. For example, this would be the key for PDFCreator. Notice that calling msiexec for this product would not work.

post-54985-0-89695100-1346971257_thumb.p

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hi JLogan,

I already take a look at the uninstall string for this product like you mention above. The uninstall string exactly same like what i'm write in the code and i still don't understand why the uninstallation not successful. You can see from the screenshot below for this product uninstall string.

post-68773-0-35494900-1346989369_thumb.p

Link to comment
Share on other sites

You could just ShellExecute the program using the UninstallString information and add the /qb switch to make it a silent uninstall, then it won't matter what the program needed to actually run the uninstall is.

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

BrewManNH, yes it doesn't matter what the program needed to actually run the uninstall but the problem is even i'm using the uninstall string above the application still not remove. The only way i can remove it by using cmd with admin right and paste the uninstall string then the uninstallation successful. Is there any way i can uninstall this application by running cmd with admin privilege and paste the uninstall string automatically by the script? How can i write a script to do so? Please assist me.

thanks.

Link to comment
Share on other sites

Put #RequireAdmin at the top of your script, then the script will be running under an admin's credentials.

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,

After i'm searching the post that have similar issues with my post in a few hours, i've finally found the problem what makes my code not running as expected. The problem is coming from the logon_flag which i supposedly put 1 instead of 0 in the code. This solution coming after i read this post

$sUser = "username"
$sPass = "password"
$sDomain = "domain"
$sCMD1 = "msiexec.exe /x{product code} /qn /norestart"
$sCMD2 = "msiexec.exe /x{product code} /qn /norestart"
RunAsWait ($sUser, $sDomain, $sPass, 1, "cmd /c " & $sCMD1, "", @SW_HIDE)
RunAsWait ($sUser, $sDomain, $sPass, 1, "cmd /c " & $sCMD2, "", @SW_HIDE)

Anyway thanks everyone for the help.. :)

Cheers!

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...