ahmet Posted March 16, 2018 Posted March 16, 2018 Hello, I am trying to make a program that will uninstall some software, provided by some form of a list. I have this ; Generated by AutoIt Scriptomatic June 08, 2010 ;#RequireAdmin $sPartialName="java" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $strComputer = "localhost" ;$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") ;$objWMIService=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $objWMIService=ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Product", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems If StringInStr($objItem.Name,$sPartialName)=1 Then ConsoleWrite("Full name:" & $objItem.Name & @CRLF) RunAs("USERNAME",@ComputerName,"PASSWORD",0,@ComSpec & " /c" & ' wmic product where name="Java 9.0.4 (64-bit)" call uninstall /nointeractive',"C:\WINDOWS\system32\wbem",@SW_MAXIMIZE) ;Run('wmic product where name="Java 9.0.4 (64-bit)" call uninstall /nointeractive',"",@SW_MAXIMIZE) ExitLoop EndIf Next Else Msgbox(0,"WMI Output","No WMI Objects Found for class: " & "Win32_Product" ) Endif The script above fails uninstalling software despite providing username and password for admin account. If I run script with admin rights then the software gets uninstalled. At the following link there is a script by JLogan3o13 but it does not either uninstall software, unless run as admin.. Is there some way to uninstall software using wim or wimc by providing user name and password?
Moderators JLogan3o13 Posted March 16, 2018 Moderators Posted March 16, 2018 Just to clarify, you want to be able to run it and pass credentials rather than seeing the UAC prompt, is that correct? If that is the case, I would compile the uninstall script, and then from a second script run the compiled one with the RunAs (look in the help file) function - passing the username and password. Earthshine 1 "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!
ahmet Posted March 16, 2018 Author Posted March 16, 2018 Thank you for your help. Then I will most probably do it that way, if end user agrees.
rcmaehl Posted March 16, 2018 Posted March 16, 2018 1 hour ago, ahmet said: Thank you for your help. Then I will most probably do it that way, if end user agrees. You can also use FileInstall to package the uninstall script with the script that runs it. (When Compiled) Earthshine 1 My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated. My Projects WhyNotWin11, MSEdgeRedirect Cisco Finesse, Github, IRC UDF, WindowEx UDF
bernd670 Posted April 4, 2018 Posted April 4, 2018 Hello, you can run wmic with a partial Productname wmic product where "name like '%java%'" list for uninstall try this RunAs("USERNAME", @ComputerName, "PASSWORD", 2,"wmic product where ""name like '%java 9%'"" call uninstall /nointeractive", @SystemDir & "\wbem", @SW_MAXIMIZE) use logon_flag 2 greetingsbernd I hacked 127.0.0.1 ->
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now