Jump to content

Recommended Posts

Hello everyone, 

I'm working on a WMIC uninstaller. A quite simple one with a button to display product names in a editable list (for copy/paste purposes) but the main problem is that in order to achieve this, in my corporation, normal users cannot uninstall softs.

What I found/adapt so far:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("wmic uninstaller", 300, 152, 337, 380)

$Label1 = GUICtrlCreateLabel("Computername", 0, 8, 75, 17)
$Input1 = GUICtrlCreateInput(@ComputerName, 0, 32, 125, 21)

$Label2 = GUICtrlCreateLabel("wmic command", 150, 8, 77, 17)
$Combo1 = GUICtrlCreateCombo("Model_Computer", 150, 32, 125, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))

GUICtrlSetData(-1, "Current_user|Installed_Apps|Serial_Number|Bios_Version")

$Button1 = GUICtrlCreateButton("List Apps", 150, 72, 91, 49)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
         case $button1
            $wmi = GUICtrlRead($combo1)
            $pc = GUICtrlRead($input1)
            call($wmi,$pc)

    EndSwitch
 WEnd
 
 Func Model_Computer($pc)
RunWait(@ComSpec & ' /c ' & 'wmic /node:' & $pc &' product get name > %temp%\apps.txt' ,"", @SW_HIDE)
$file=(@TempDir & "/apps.txt")
$fileread= FileRead($file)
MsgBox(0, $pc , $fileread)
FileDelete(@TempDir & "/apps.txt")
EndFunc

Here's the textual version I gave to my techs:

Create cmd shortcut on Desktop, run it as a different user (using their own admin accounts).
Once opened, type wmic
Once wmic loaded, type product get name
Wait for the list of installed soft to display
Type product where name="Exact App name" call uninstall
Type "Y" to confirm
Wait for task execution
Don't care about exit code
App is uninstalled (verified by getting the list again)!

In fact, I'd like to automatize this process.

Any ideas over here? :)

Thanks ^^


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites

This is what I use, you could easily wrap a GUI around it:

#include <MsgBoxConstants.au3>

$sName = InputBox("Uninstall Wizard", "Please type the first few letters of the application name to search")
$oWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & @ComputerName & "\root\cimv2")
$aProducts = $oWMI.ExecQuery("Select * from Win32_Product Where Name LIKE '%" & $sName & "%'")

For $app in $aProducts
    $popup = MsgBox($MB_YESNOCANCEL, "Uninstall Wizard", "Would you like to uninstall " & $app.Name & "?")
        If $popup = $IDYES Then
            $app.Uninstall()
        ElseIf $popup = $IDCANCEL Then
            ExitLoop
        EndIf
Next

 

Share this post


Link to post
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

  • Similar Content

    • By KingOfNothing
      This is for mac address spoofing.
      Before a mod gives me the ban hammer for posting code such as this, id like to explain I recently had a necessity for it.
      A lot of places use mac addresses to identify devices/machines and control internet permissions.
      I myself love the xfinity wifi hotspots placed all around where I live as I can connect to them and save data usage instead of tethering my phone.
      BUT! They use a captive portal with a webpage interface in javascript and (not too much to my surprise), wifey says some of her crap wont open that page.
      I explained she can disable wifi on the device, use computer and spoof to the mac address of what she wants to use. Then sign into the portal as she would normally with computer.
      Once connected, shut the computer down and enable wifi for that device again. Once enabled shes got net access. edit: Wife looked at me like I was speaking latin.....lol
      ; ; ; Function: Set_Mac() ; ; Parameter(s): $s_Desired_Mac = Need I really explain? ; $s_Target_Net_Adapter = Network adapter name (one can use the adapter index as well but thats less "user friendly" ; $b_Toggle_Device = For my wife cuz it needs full automation for her to stop bothering me ; ; Author(s): KingOfNothing credz to google & autoitscript.com members ; ; ;===================================================================== Opt('MustDeclareVars', 0) ;cause its late in the morning and im just gonna trust this should still fly #include <WinApi.au3> $MacAddressRegKey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0007" ; ^^^ After making this I read online that this should be some "CurrentControlSet" ; key instead. However, I watched registry while changing things in adapter properties ; to see that key, which works fine on my 3 test machines.... ;easy example Set_Mac("Wireless Network Connection","",true) ;msgbox(0,"",Get_Mac()) Func Set_Mac($s_Targeted_Adapter, $s_Desired_Mac = "D20000000000", $b_Toggle_Device = true ) Local $sMac, $s_Tmp, $val, $sVar = "" $sMac = Get_Mac() while stringlen($s_Desired_Mac)< 12 and stringlen($s_Desired_Mac)> 0 ;this will append zeros if mac length is too short $s_Desired_Mac = $s_Desired_Mac & "0" wend if stringlen($s_Desired_Mac)> 12 then ;likewise if too many characters entered to function, then we should truincate some $s_Desired_Mac = StringLeft ($s_Desired_Mac,12) endif ;this creates a random mac address with very little actual thought behind it. ;Im sure theres some formal means to devising a valid mac address but this simple crap suits my needs atm.... if $s_Desired_Mac = "" then For $i = 1 To 10 $sVar= Chr(Random(48, 57, 1)) ;0-9 $s_Tmp = $s_Tmp & $sVar Next $s_Desired_Mac = "D2" & $s_Tmp $s_Desired_Mac = StringUpper($s_Desired_Mac) endif $val = RegWrite($MacAddressRegKey, "NetworkAddress", "REG_SZ", $s_Desired_Mac) if $val =0 then MsgBox(0,"Mac Address Changer ","Could not write to registry as needed to change your mac address!" & @CRLF & "Please restart this program with administrator rights!") Exit endif ;in order to benifit from changing the registry, one must disable/re-enable the adapter. ;This cmd line query to wmic prevents the need to do so in device manager manually if $b_Toggle_Device = true then ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe", "path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call disable" ,"",$SHEX_OPEN,@SW_HIDE) ShellExecuteWait ("C:\Windows\System32\wbem\wmic.exe","path win32_networkadapter where NetConnectionID=" & chr(34) & $s_Targeted_Adapter & chr(34) & " call enable" ,"",$SHEX_OPEN,@SW_HIDE) endif ;Would be smart to catch the return of the function there in some varible for error handling, but its too late for me to give a crap atm.... MsgBox(0,"Mac Address Changer", "Old Mac = " & $sMac & @crlf & "New Mac = " & $s_Desired_Mac) clipput($s_Desired_Mac) endfunc Func Get_Mac() Local $xRet $xRet= RegRead($MacAddressRegKey, "NetworkAddress") return $xRet EndFunc  
      Sorry bout the messy penmenship. Aint looked at the tidy thing yet....🧐
    • By nitron
      Hy All,
       
      again I got a question.
      I try to convert
      wmic PATH Win32_videocontroller GET adapterram
       
      i tried to to it like in this example but my knoledge is not good enough
         Local $oWMI = ObjGet("winmgmts:root\CIMV2")
         Local $oDisks = $oWMI.ExecQuery("select * from WIN32_DiskDrive")
       
      So i tired 
         Local $oWMI = ObjGet("winmgmts:root\CIMV2")
         Local $oGMRam= $oWMI.ExecQuery("Win32_videocontroller")
         $Memory=$oGMRam.adapterram
      but this does not work.
      I like to understand what i need to do?
       
    • By Psyllex
      I'm trying to install some setup stuff on Win10. 
       
      One part of the script requires just regular user privileges but the other requires admin privileges.  When I run it from the Autoit Editor it works like a champ.  When I build it, Windows slaps the admin stamp on it and then when I attempt to run the part that only requires regular users....it gets all hosed up. 
      Is there a way to remove #RequireAdmin? 

      I've tried RunAs(username, "", myPassword, "", "cmd.exe", "") but that never seems to work.
      Can someone help me out?
    • By vyperhand
      I have an application that due to strange architecture will NOT uninstall as the system account.  As such, I have to pass credentials in order to uninstall it.  The commands I am trying run to accomplish this do not generate any errors, but they're not actually completing successfully.
      The $XUser and $XPass are defined as Local variables inside my function and are the username and password for a local admin account.  I have tried these variants on the command with no success:
      RunAsWait($XUser, @ComputerName, $XPass, $RUN_LOGON_NOPROFILE, "MsiExec.exe /x {DB7DE612-0D4F-49B5-B6B3-A42340856F7D} /qn") RunAsWait($XUser, @ComputerName, $XPass, $RUN_LOGON_NOPROFILE, @ComSpec & " /k " & "MsiExec.exe /x {DB7DE612-0D4F-49B5-B6B3-A42340856F7D} /qn") Simply calling "MsiExec.exe /x {DB7DE612-0D4F-49B5-B6B3-A42340856F7D} /qn" from a command prompt removes the software, so I know that command and GUID are correct.
      Any help would be greatly appreciated.
       
    • By nacerbaaziz
      Hello all
      I have a question please
      Is there a way to request the script for administrator privileges if a particular condition is met??
      example
      local $path = RegRead("HKEY_CURRENT_USER\Software\test", "fullpath")
      if $fullPath = @scriptFullPath then
      Request for administrator privileges
      main()
      else
      main()
      endIf
      I hope to find a solution here
      Greetings to all
×
×
  • Create New...