bqp2 Posted November 19, 2010 Share Posted November 19, 2010 Okay script installs a app then when it goes to uninstall it i can't use the uninstall string with _rundos cause the string changes the random number or letter.bin dir to so im using mouseclick to goto add remove prrograms, and this works great if app is there but if by some chance the app didn't install it trys to uninstall whatever is usually in its place which doesnt get installed cause mouseclicks are different location but when script continues there is a box blocking the screen so scrip just hangs all night so is there a if program exsist in add remove programs then uninstall process end if if so what would be the correct code for that Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted November 19, 2010 Moderators Share Posted November 19, 2010 I've encountered this as well, though mostly remote machines in my case. You might try something similar to what is below; it works for me on anything installed through an MSI or Setup.exe. It does NOT work on what I like to call "crap apps" like toolbars that will not allow you to do silent uninstalls. I also use the second script to give me a quick view of what is installed on a remote machine, if you just want to see what's there. One of these days I'll get around to combining the two, to give a more visual representation rather than having to go through each application looking for the one you want:Remote Uninstall:expandcollapse popup;get remote computer name $sMachine = InputBox("Computer name?", "Uninstall Remote Application") ;get admin credentials Dim $sAdminUser, $sPassword $sAdminUser = ("[color="#ff0000"][b]Your Username[/b][/color]") $sPassword = ("[color="#ff0000"][b]Your Password[/b][/color]") ;get a WMI Locator Dim $oLocator $oLocator = ObjCreate("WbemScripting.SWbemLocator") ;connect to the remote machine Dim $oService, $oLocator $oService = $oLocator.ConnectServer($sMachine, "root\cimv2", _ $sAdminUser, $sPassword) ;get a list of installed products Dim $sMsg, $sName $cProducts = $oService.ExecQuery("SELECT * " & _ "FROM Win32_Product") For $oProduct in $cProducts $sMsg = MsgBox(4, "Product: " & $oProduct, "Would you like to uninstall: " & $oProduct.Name & "?") If $sMsg = 6 Then $sName = $oProduct.Name ExitLoop EndIf Next ;Get the named package $cProducts = $oService.ExecQuery("SELECT * " & _ "FROM Win32_Product WHERE Name = '" & _ $sName & "'") For $oProduct in $cProducts ;uninstall it $oProduct.Uninstall MsgBox(0, "Uninstall Complete.", "Uninstalled " & $sName) NextEnumerate Remote Apps (Completed only with the help of AutoIT Forum Members. Thanks!):#include <Array.au3> $Computer = InputBox( "Enter Asset Tag", "What machine would you like to connect to?" ) $ret = _SoftwareInfo() _ArrayDisplay($ret, '') Func _SoftwareInfo($s_RemoteComputer = $Computer) Local $Count = 1 If $s_RemoteComputer <> '' Then $s_RemoteComputer = '\\' & StringReplace($s_RemoteComputer, '\', '') & '\' Local Const $regkey = $s_RemoteComputer & 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' While 1 $key = RegEnumKey ($regkey, $Count) If @error <> 0 then ExitLoop $line = RegRead ($regkey & '\' & $key, 'Displayname') $line = StringReplace ($line, ' (remove only)', '') If $line <> '' Then If Not IsDeclared('avArray') Then Dim $avArray[1] ReDim $avArray[UBound($avArray) + 1] $avArray[UBound($avArray) - 1] = $line EndIf $Count = $Count + 1 WEnd If Not IsDeclared('avArray') Or Not IsArray($avArray) Then Return(SetError(1, 0, '')) Else $avArray[0] = UBound($avArray) - 1 Return(SetError(0,0, $avArray)) EndIf EndFunc "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 More sharing options...
Syed23 Posted January 31, 2011 Share Posted January 31, 2011 Hi Friends, Sorry for disturbing you.. this Script is very useful to me but also i want to get the Uninstall string detail for all the application. is that possible ? Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font] Link to comment Share on other sites More sharing options...
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