Script for uninstalling an Outlook add-in administratively (.exe)

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!
0
the
1/28/2010 9:14:52 PM
scripting.vbscript 564 articles. 0 followers. Follow

5 Replies
2037 Views

Similar Articles

[PageSpeed] 45

Can you list what the value for UninstallString=3Dx is when it's done
enumerating the keys?

the /qn switch for msiexec should remove it quietly.

On Jan 28, 4:14=A0pm, the keylime <dwayne.hoff...@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 =3D "."
> set objShell =3D CreateObject("WScript.Shell")
>
> '=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> AppToRemove =3D "Cisco MeetingPlace for Outlook"
>
> '
> strMSI =3D UninstallString(AppToRemove)
> If strMSI<>"" Then
> =A0 =A0 =A0 =A0 wscript.echo strMSI
> =A0 =A0 =A0 =A0 objShell.Run strMSI
> End If
>
> function UninstallString(strProductName)
> =A0 =A0 =A0 =A0 dim strComputer, oReg, strKeyPath, arrSubKeys, subkey, x
> =A0 =A0 =A0 =A0 Const HKEY_LOCAL_MACHINE =3D &H80000002
> =A0 =A0 =A0 =A0 strComputer =3D "."
>
> =A0 =A0 =A0 =A0 Set oReg=3DGetObject("winmgmts:{impersonationLevel=3Dimpe=
rsonate}!\\" &
> strComputer & "\root\default:StdRegProv")
>
> =A0 =A0 =A0 =A0 ' Get array of subkeys under uninstall registry entry
> =A0 =A0 =A0 =A0 strKeyPath =3D "SOFTWARE\microsoft\windows\currentversion=
\uninstall"
> =A0 =A0 =A0 =A0 oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
>
> =A0 =A0 =A0 =A0 For Each subkey In arrSubKeys
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 x=3DFindUninstallString(subkey, strProduc=
tName)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if x<>"" then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if LCase(Left(x,7))=3D"ms=
iexec" then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ' Check m=
siexec for parameters...
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if InStr(=
1,x,"/I")>0 then x=3DReplace(x, "/I","/X")
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if InStr(=
1,x,"/q")<1 then x=3Dx & " /q"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if InStr(=
1,x,"/noreboot")<1 then x=3Dx & " /noreboot"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end if
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 UninstallString=3Dx
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 exit function
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end if
> =A0 =A0 =A0 =A0 Next
> end function
>
> function FindUninstallString(strKey, strProductName)
> =A0 =A0 =A0 =A0 dim DisplayName, Publisher, UninstallString, search
> =A0 =A0 =A0 =A0 On Error Resume Next
> =A0 =A0 =A0 =A0 DisplayName=3DobjShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTW=
ARE
> \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey &
> "\DisplayName")
> =A0 =A0 =A0 =A0 WshShell.SendKeys "{ENTER}"
> =A0 =A0 =A0 =A0 Publisher=3DobjShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWAR=
E\Microsoft
> \Windows\CurrentVersion\Uninstall\" & strKey & "\Publisher")
> =A0 =A0 =A0 =A0 WshShell.SendKeys "{LEFT}""{ENTER}"
> =A0 =A0 =A0 =A0 UninstallString=3DobjShell.RegRead ("HKEY_LOCAL_MACHINE\S=
OFTWARE
> \Microsoft\Windows\CurrentVersion\Uninstall\" & strKey &
> "\UninstallString")
> =A0 =A0 =A0 =A0 WshShell.SendKeys "{ENTER}"
> =A0 =A0 =A0 =A0 search =3D Instr(1, DisplayName, strProductName, 1)
>
> =A0 =A0 =A0 =A0 ' Get uninstall string
> =A0 =A0 =A0 =A0 if search>0 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if UninstallString=3D"" then UninstallStr=
ing=3D"MsiExec.exe /X" & strKey
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FindUninstallString =3D UninstallString
> =A0 =A0 =A0 =A0 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!

0
Corey
1/29/2010 12:58:32 PM
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
0
the
1/29/2010 1:17:24 PM
In the past I have had to call Wscript.Sleep() before SendKeys simply because 
a dialogbox is being presented it is possible that the script will execute 
faster and since your suppressing errors you get no notification of this.


0
Utf
1/29/2010 4:55:01 PM
The issue with the Sleep command is, it doesn't work here. I am
getting errors when the script runs. The SetTimeout flag isn't working
either.

0
the
1/29/2010 5:04:34 PM
"I am getting errors when the script runs."

What errors? You stated earlier that the script performs the uninstall. Why 
do you have the elaborate function to find the product code. Why not just 
manually add the product code objShell.Run "MsiExec.exe /Q/X{ProductCode}" 
Then if there is user interaction required ie. "Do you wish to uninstall this 
product?" you can wait then use SendKeys

"the keylime" wrote:

> The issue with the Sleep command is, it doesn't work here. I am
> getting errors when the script runs. The SetTimeout flag isn't working
> either.
> 
> .
> 
0
Utf
1/29/2010 6:19:01 PM
Reply:

Similar Artilces:

Hotmail no OutLook
Eu gostaria de configurar meu endere�o de e-mail no hotmail, mas nao consigo pq acho q o servidor est� errado....... podem me ajudar? ¿Esto es una cuenta pagada de hotmail? -- Kathleen Orland Outlook Tips: http://www.outlook-tips.net/ http://www.howto-outlook.com/ Outlook & Exchange Solutions Center: http://www.slipstick.com "Pércoles Tiago Napivoski" wrote: > Eu gostaria de configurar meu endereço de e-mail no hotmail, mas nao consigo > pq acho q o servidor está errado....... podem me ajudar? > > > ...

Outlook Express and Outlook 2000
Hi, I have a PC with Outlook Express (v5) and Outlook 2000 installed. When using the send as email in Word/Excel etc Outlook Express i always fired up. I want to use Outlook 2000 as the default - how do go about changing this? Thanks in advance, Ton ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com Control Panel | Internet Options | Programs tab...make sure Outlook is listed as the default mail program. -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail...

Update Outlook 2k for SSL?
W2k sp4 on a little desktop system, DSL (1.2 mbps download) I got Email from ISP ATT stating that Email must be SSL for continued service. Per Outlook "help", I am running: Outlook 2k 9.0.0.2711 Corporate or workgrp 40 bit (Export version) I followed numerous MS links. Appears I need to apply O2k SR1/1a, then extensions to encryption, then ??? to get SSL support. I even tried to download SR1 from: http://www.microsoft.com/office/ork/2000/appndx/toolbox.htm#o2sr1au and got the infamous "The page cannot be found". Maybe a good thing: I don't really know what ...

Is there a way to add classifications to Investments
Hi here is what i want. I have Investment transactions BUY: , SELL: and i want to add a classification to it Family Member : XYZ how do i do that with MS Money 2004? Thanks Cyrus In microsoft.public.money, Cyrus Jamula wrote: > > >here is what i want. >I have Investment transactions >BUY: , SELL: > >and i want to add a classification to it >Family Member : XYZ > >how do i do that with MS Money 2004? You can't. What you *can* do is to add a Memo including something unique to the family member (the name probably). Customize the Investment Transactions re...

Invalid page fault in outlook
need some help: OUTLOOK caused an invalid page fault in module MSOUPLUG.DLL at 0167:10016d58. Registers: EAX=0056f874 CS=0167 EIP=10016d58 EFLGS=00010216 EBX=021e4240 SS=016f ESP=0056f550 EBP=0056f880 ECX=00000000 DS=016f ESI=021e50bc FS=4157 EDX=0056f55c ES=016f EDI=10027924 GS=0000 Bytes at CS:EIP: 8b 01 57 c7 44 24 20 00 00 00 00 ff 50 18 3d 00 Stack dump: 0056f55c 021e4f41 021e4244 00000000 00000104 0056f874 10026058 ffffffff 100140c7 10027924 100278cc 021e4f41 00000001 007917f0 00792dec bff80555 ...

Reject script in pass through san script not working
I have a scenario that i had to check for dependencies of divisions(Human Resources) before their deletion and decide whether to let deletion proceed or not, i had done this for many entities like department(Dynamics) in my development dictionary, i registered a focus trigger before delete button of department form and checked dependencies for it on triggered script and allow or prevent deletion successfully. Now for division that is in the human resources dictionary i registered a cross-dictionary focus trigger to run before delete buttons change event as result = Trigger_RegisterFocus...

Sort Column Script
I need to have a script in Excel that would allow the sorting of columns from column "D" to the column before the last column with data. I do not want the last column sorted. The criteria for the sort is in row 1 (Name of an employee). Additional columns will be inserted between column "D" and the last column so they need to be sorted. I hope this is clear. Can someone please assist me? Thank you! Bernie Bernie How can someone named Bernie NOT know how to do this? ;-) Sub BernieSort() Range(Range(Range("D1"), Range("D1").End(xlDown)), _ ...

Outlook with Exchange server
Hi All, I am using outlook with exchange server to receive email and schedule calendar, but I want to leave a copy of message on server when outook receives email, how can I configure the outlook client? Thanks in advance, Rabbit "Rabbit" <rabbitxu@163.com> wrote in news:u0yKX4jPFHA.880 @TK2MSFTNGP15.phx.gbl: > Hi All, > > I am using outlook with exchange server to receive email and schedule > calendar, but I want to leave a copy of message on server when outook > receives email, how can I configure the outlook client? > > Thanks in advance, > Ra...

Finding items (with Outlook 2003)
When doing "Advanced Find", I type "2008-" (without the quotes) in the "Search for Word(s):" box, specify "in Subject Field Only" and click "Find Now". the results contain "2008-" ANYWHERE in the "Subject". How can I do the find so the results contain "2008-" only AT THE BEGINNING of the "Subject"? Did you try the Advanced tab? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com Outlook Tips by email: mailto:da...

Outlook 98 vs Outlook Express 6.0
I have been using Outlook 98 for Email. I send and receive messages with attachments of up to probably 3mb in size. My Inbox has about 20 sub-folders in which I keep messages. I have NOT been successful in backing up any of those folders or the entire *.pst file for that matter. It APPEARS that Outlook Express 6.0 will allow various folders to be backed up at will by dragging those that I care to keep to the CDRW. What features would I loose if I were to discontinue using Outlook 98 and process all of my Email on Outlook Express 6.0??? To me it appears that I would not loose anything. W...

Outlook 2007 Folder Status Notification
I am having issues w/the Folder Status message. It used to tell me "All folders are up to date.", now it is just saying "This folder is up to date." Anyway to make it go back? I am using a corporate version of XP as the OS if you need that. Thanks, Sophie ...

outlook.exe faulting module outllib.dll
Hi all! My one user having problems with Outlook 2003. User complains it moslty craches when he working with Calendar. Event viewer states: Faulting application outlook.exe, version 11.0.8118.0, stamp 456628bf, faulting module outllib.dll, version 11.0.8118.0, stamp 4566283d, debug? 0, fault address 0x0000355f. For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp. both WindowsXP PRo and Office 2003 upto date. How to solve this problem, regards, toxikas Is there any way to report these issues to M$ so we can get a proper update that will n...

how to add one same word on every 10th line
hi, i have excel with 50000 lines.i have to insert this word "###break###" on every 10 th line.how to do this? i tried macro but cannot able to do.i need help.advance thanks for your help. -- elavenil ------------------------------------------------------------------------ elavenil's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=37522 View this thread: http://www.excelforum.com/showthread.php?threadid=571672 here's a macro you can use. Just modify it to suit your needs. Sub test() Dim i As Long For i = 1 To 5000 Sheets(1).Range(&qu...

I want to use Outlook, not Outlook Express
When I try to open Outlook it says the server is not responding, however, I can get my mail using Outlook Express. How do I set up so Outlook is my default mail server? I've always used Express since I got my computer. I want to make sure I still can use my existing email address by using Outlook only, not Express. Outlook is not a server. Outlook is an email client. The "server is not responding" message is because the incoming or outgoing server you have specified in your Outlook email account settings is incorrect. Double, no, triple-check the values in Outlook are the...

Default outlook setup for new users.
Windows XP Pro Outlook 2003 I am trying to figure out a way to setup outlook 2003 to have a default setup for any user that logs onto a computer. Example.. Outlook 2003 would be configured for Exchange with a default server and that persons username(%username%) already filled out. Found what I was looking for, need to use the O2k3 Resource Kit;.. Now my question is what about default office 2003 profile that sets a workgroup templete. "Dan" <nospam.dsaults.a_t.comcast.net-nospam> wrote in message news:u6%23NDgv1EHA.3392@TK2MSFTNGP10.phx.gbl... > Windows XP Pro &...

Business Portal Install/Uninstall
We are attempting to install Business Portal 2.0 for 7.5 on a new SBS server, but I continue to run into the following error message: "A Business Portal application is already installed. If you want to upgrade this installation, you must contact your sales consultant. If you want to install a NEW version of Business Portal, you must first uninstall the existing software. However, be aware that any changes you have made to the existing installation will be lost." The server is already running Sharepoint Portal Server, but I have been following the instructions in the cores...

Outlook 2000 Send/receive #2
I would like to know what's the difference between using "Send / Receive" and "Sychronize" in Outlook 2000. I really need to know this piece of info badly. Thanks!! Send/receive sends and receives your mail items. Synchronize creates a copy of your mailbox items on your Exchange Server on your local .ost. Hope you pass the test. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching goo...

pst file (again) 2003 Outlook
Why can't I see (or find) my pst file? I am looking in C:\Documents and Settings\Owner\Application Data\Microsoft\Outlook and all I see is Outlook.NK2 and Outlook.srs, no pst file THe program works correctly and when I go to "Data File Management" and double click on my renamed_File, it showe in the path that the file is named Outlook.pst. "TC" <tc@conecap.com> wrote in message news:ef05d458-82b8-41c3-b8a4-c885938dfabe@x21g2000yqa.googlegroups.com... > Why can't I see (or find) my pst file? I am looking in C:\Documents > and Settings\Owner\Applicati...

Script error found during opening Dynamics
I just upgrade to the latest Canada Payroll tax update, when one of the user who sign on to Dynamics after upgrade, she got the "Internet Explorer Script Error" window pop up and saying "An error has occurred in the script on this page" Line: 335 Char: 6 Error: The data is invalid Code: 0 URL: file:///C:/Documents%20and%20Settings/UserA/Local%20Settings/Temp/tmpAD1.tmp I tried to clear all the temp file in this folder but still no luck to get rid of this message during loading Dynamics. I asked the user to click on "Yes" button to continue "D...

VBA script help..Please !!!!
I have been given the script below by Ron De Bruin - and I can't thank him enough, however I'm still scratching my head as it doesn't EXACTLY what I want. I want ALL the built in command bars/toolbars etc that are shown in a normal excel sheet to be hidden when I open my 'Log' - EXCEPT my own personal toolbar named 'LOG' and the 'Worksheet Menu Bar'. 2 problems arise from the script below :- 1) The Worksheet Menu Bar is displayed, but my 'LOG' toolbar is not. 2) If I open another seperate excel sheet, all the same commands have been copied to...

Outlook 2000 Advanced Find feature
When utilizing Outlook 2000 Advanced Find feature to locate messages with a particular keyword in the message body, messages that have been signed do not appear in the list of identified messages. I do not know if that means Outlook ignores all signed messages or if the message is somehow altered in a way that defeats the find feature. ...

creating an outlook 2003 view to show mail older than x days
Does anyone know how to create views in outlook 2003 that show mail older than x days? Regards Russell view menu... find current view, define views. create an advanced filter using date criteria on or before and enter a date or xx days ago format. (you can also use advanced find and search for messages xx days ago) -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Outlook Tips: http://www.outlook-tips.net/ http://www.poremsky.com - http://www.cdolive.com Expert Zone http://www.microsoft.com/windo...

Synchronizing Outlook on desktop to laptop
I have my laptop networked to my desktop and want to be able to maintain identical Outlook folders or at least contacts and calendar. Has any one tried Synchpst? Do you recommend it? See http://www.slipstick.com/outlook/sync.htm for a list of options... RustyMoran wrote: > I have my laptop networked to my desktop and want to be able to > maintain identical Outlook folders or at least contacts and calendar. > Has any one tried Synchpst? Do you recommend it? ...

Outlook Viewer
Hi, As Microsoft produce read-only viewers for other apps in the Office suite (Word Viewer, Excel Viewer, PowerPoint Viewer etc), do they also produce a viewer for .pst files...? I've had a bit of a trawl round Google and can't find one, so I'm assuming they don't... Mark No. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ Outlook 2007: http://www.slipstick.com/outlook/ol2007/ Outlook Tips by email: dailytips-subscribe-request@lists.outlooktips.net Outlook Tips: ht...

Unable to Display the View
I got this error yesterday and was unable to display ANY of my Outlook folders. I spent an inordinate amount of time trying to get it fixed and then discovered a thread about creating a new profile, which I ultimately did. This worked OK, but now I'm getting the same message again, less than 24 hours later. What do I need to do to fix this? Thanks. The exact message is "Outlook cannot display this view." I just ran the Inbox Repair Tool. Afterword, it worked for a while and now I'm getting the same message again. Please help. "MadDog" <M...