31290 Posted October 7, 2015 Posted October 7, 2015 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:expandcollapse popup#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") EndFuncHere'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 wmicOnce wmic loaded, type product get nameWait for the list of installed soft to displayType product where name="Exact App name" call uninstallType "Y" to confirmWait for task executionDon't care about exit codeApp 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 ~~~
Moderators JLogan3o13 Posted October 7, 2015 Moderators Posted October 7, 2015 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 31290 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!
31290 Posted October 7, 2015 Author Posted October 7, 2015 Hell yeah! That's just awesome. No need to user admin credentials or so... Your core have done my script! Piece of cake now Thanks a lot for that ~~~ Doom Shall Never Die, Only The Players ~~~
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