Prev: start IE in protected mode
Next: How to create a share and set the NTFS rights *in a remote computer*?
From: the keylime on 28 Jan 2010 16:14 I have this script that I am trying to automate, but the Send Keys are not working: Option Explicit Dim strComputer, strMSI, MSIapp, App, AppToRemove, objShell strComputer = "." set objShell = CreateObject("WScript.Shell") '======================================== AppToRemove = "Cisco MeetingPlace for Outlook" ' strMSI = UninstallString(AppToRemove) If strMSI<>"" Then wscript.echo strMSI objShell.Run strMSI End If function UninstallString(strProductName) dim strComputer, oReg, strKeyPath, arrSubKeys, subkey, x Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") ' Get array of subkeys under uninstall registry entry strKeyPath = "SOFTWARE\microsoft\windows\currentversion\uninstall" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys For Each subkey In arrSubKeys x=FindUninstallString(subkey, strProductName) if x<>"" then if LCase(Left(x,7))="msiexec" then ' Check msiexec for parameters... if InStr(1,x,"/I")>0 then x=Replace(x, "/I","/X") if InStr(1,x,"/q")<1 then x=x & " /q" if InStr(1,x,"/noreboot")<1 then x=x & " /noreboot" end if UninstallString=x exit function end if Next end function function FindUninstallString(strKey, strProductName) dim DisplayName, Publisher, UninstallString, search On Error Resume Next DisplayName=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey & "\DisplayName") WshShell.SendKeys "{ENTER}" Publisher=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft \Windows\CurrentVersion\Uninstall\" & strKey & "\Publisher") WshShell.SendKeys "{LEFT}""{ENTER}" UninstallString=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey & "\UninstallString") WshShell.SendKeys "{ENTER}" search = Instr(1, DisplayName, strProductName, 1) ' Get uninstall string if search>0 Then if UninstallString="" then UninstallString="MsiExec.exe /X" & strKey FindUninstallString = UninstallString end if end function The script does uninstall but requires user interaction. We are going to deploy this script via GPO and would like to automate it. How would I do that? Thanks!
From: Corey Thomas on 29 Jan 2010 07:58 Can you list what the value for UninstallString=x is when it's done enumerating the keys? the /qn switch for msiexec should remove it quietly. On Jan 28, 4:14 pm, the keylime <dwayne.hoff...(a)gmail.com> wrote: > I have this script that I am trying to automate, but the Send Keys are > not working: > > Option Explicit > > Dim strComputer, strMSI, MSIapp, App, AppToRemove, objShell > > strComputer = "." > set objShell = CreateObject("WScript.Shell") > > '======================================== > AppToRemove = "Cisco MeetingPlace for Outlook" > > ' > strMSI = UninstallString(AppToRemove) > If strMSI<>"" Then > wscript.echo strMSI > objShell.Run strMSI > End If > > function UninstallString(strProductName) > dim strComputer, oReg, strKeyPath, arrSubKeys, subkey, x > Const HKEY_LOCAL_MACHINE = &H80000002 > strComputer = "." > > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & > strComputer & "\root\default:StdRegProv") > > ' Get array of subkeys under uninstall registry entry > strKeyPath = "SOFTWARE\microsoft\windows\currentversion\uninstall" > oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys > > For Each subkey In arrSubKeys > x=FindUninstallString(subkey, strProductName) > if x<>"" then > if LCase(Left(x,7))="msiexec" then > ' Check msiexec for parameters... > if InStr(1,x,"/I")>0 then x=Replace(x, "/I","/X") > if InStr(1,x,"/q")<1 then x=x & " /q" > if InStr(1,x,"/noreboot")<1 then x=x & " /noreboot" > end if > UninstallString=x > exit function > end if > Next > end function > > function FindUninstallString(strKey, strProductName) > dim DisplayName, Publisher, UninstallString, search > On Error Resume Next > DisplayName=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE > \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey & > "\DisplayName") > WshShell.SendKeys "{ENTER}" > Publisher=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft > \Windows\CurrentVersion\Uninstall\" & strKey & "\Publisher") > WshShell.SendKeys "{LEFT}""{ENTER}" > UninstallString=objShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE > \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey & > "\UninstallString") > WshShell.SendKeys "{ENTER}" > search = Instr(1, DisplayName, strProductName, 1) > > ' Get uninstall string > if search>0 Then > if UninstallString="" then UninstallString="MsiExec.exe /X" & strKey > FindUninstallString = UninstallString > end if > end function > > The script does uninstall but requires user interaction. We are going > to deploy this script via GPO and would like to automate it. How would > I do that? > > Thanks!
From: the keylime on 29 Jan 2010 08:17
I'm getting the actual uninstall string for the product, followed by the prompt asking whether I want to uninstall the item, and then the acknowledgment that it's uninstalled. Uninstall string = RunDll32 advpack.dll,LaunchINFSection C:\WINDOWS\INF \MPOUTL.INF, DefaultLocation.ntx86 |