Jump to content

Recommended Posts

Posted

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
Posted

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.

"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!

Posted
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)

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
Cisco FinesseGithubIRC UDFWindowEx UDF

 

  • 3 weeks later...

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
×
×
  • Create New...