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
2089 Views

Similar Articles

[PageSpeed] 48

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:

How do you remove Outlook?
Throughout history, Outlook has been the culprit of the majority of viruses and worms. In the past, I have protected myself from these bad boys by removing Outlook. I now have Windows XP and a new computer with Microsoft office and every time I try to remove the program, it reinstalls itself. Going to "remove programs" takes out the normal visible items but when you go to "programs" and actually look at the programs, Outlook is still there. Go in and try to remove files one at a time and they reappear on their own a couple seconds later. I don't use Outlo...

Outlook 2002: delivery options
the messages are not sent at specified time and remain in Outbox. System time is correct and sending time is correct. What version of Outlook do you have? Is Outlook running at the time that the message is supposed to be delivered? -- Jeff Stephenson Outlook Development This posting is provided "AS IS" with no warranties, and confers no rights "alice" <anonymous@discussions.microsoft.com> wrote in message news:018a01c3d3b7$b3f66090$a301280a@phx.gbl... > the messages are not sent at specified time and remain in > Outbox. System time is correct and sendi...

hrlp!
eep asking for my usernsame an d password- when it was all entered during the setup bit? For Outlook 2002 on Win98, NT, or 2000: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q290684 For Outlook 2000 on Windows 2000 (check the second line here for your mode: Help menu > About): Corporate/Workgroup mode: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q275465 Internet Mail Only mode: http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q259416 For all Outlook versions on Windows XP (just ignore the parts that refer to Outlook Express): http://support.microsoft.com/...

How do I get Excel to use my normal Outlook profile when emailing
When trying to send excel files directly as attachments, I cannot get them to use my normal email profile. When I try to insert a signature it tells me that my security setting prevents activex controls on this page? It works ok if I open Outlook and attach the excel file to an email. ...

Helpsvc.exe--System hogging CPU
>>> Suddenly, with no changes in my system other than >>> >> >subscribing to a news server, on bootup I find for many >>> >> >minutes, 99% CPU usage by Helpsvc.exe--SYSTEM. >>> >> > >>> >> >What is it doing, who asked it to, and why is it >>> >> >taking so long? >> >> >> >> I doubt if it's anything to do with subscribing to this group... you're >> >> describing an old bug that seems to have reappeared for some users after >&g...

RMS Add-on Tag-along
Wondering if there is an Add-on somewhere that expands the tag-along function. Used to work with a pos software that would let the cashier pick items from a predetermined list or range. It functioned a lot like tag-along does in RMS, but it let the cashier choose from a list of items. Example: ring in a bird cage kit choose from a list of different colored cages choose from a list of different toys 3# bird seed tags along choose from a list of different treats anyone see anything similiar to this? thanks What you could do is make a lot matrix item the tag-along and have the lot mat...

two accounts in the same Outlook
Hello, I would to know that is possible, in MS Outlook 2000 similar to 'Send with' in Outlook Express that let me choose the account to send a mail. Thank you very much. Oscar "Oscar" <infoDELETETHIS@chimigrafDELETETHIS.com> wrote in message news:%23IaXAu3JEHA.1944@TK2MSFTNGP10.phx.gbl... > Hello, > > I would to know that is possible, in MS Outlook 2000 similar to 'Send with' > in Outlook Express that let me choose the account to send a mail. Thank you > very much. > > Oscar > > When you compose a new message, next to the "S...

Change setting for start window in CRM sales for outlook
Hi, How do I do to change the settings for activities on my startpage in CRM sales for outlook. I would look to add another column with the person associated to the task beeing carried out. Mattias You cannot modify any views or forms for Activities and Notes. So you cannot change anything. There is a pretty good third party product from www.c360.com that allows you to display activities however you want them. Brett Meyer CRM Team Leader/Microsoft Certified instructor "Kyhlan" wrote: > Hi, > How do I do to change the settings for activities on my startpage in CRM >...

Can't open hyperlink within Outlook message
Suddenly, without applying any updates to my PC or any Window Updates, I can no longer open any hyperlink withinin any email. Error screen appears "This operation has been cancelled due to restrictions in effect on this computer. Contact systems administrator". I am the systems admin and I have made no changes. I use Vista 64 bit. I have spent hours searching out help within Outlook, viewing Control Panel settings, etc. I'm stuck. See http://www.slipstick.com/problems/link_restrict.htm for the latest information. -- Peter Please Reply to Newsgroup...

Outlook Security Features
I have a client who needs to send web site links to his clients. However, using Outlook 2002, it only sends the shortcut, a .url file attachment. We have used the Outlook Security form on his Exchange server to allow him to send this attachments. Our concern is that his clients may also be running Outlook 2002 or higher and will have the links blocked. We notice that Outlook 2000 sends not only a shortcut file attachment, but also the actual link, ie http://www.microsoft.com in the text of the message. How can we get Outlook 2002 to do this? Thank you. Larry -- Larry Lentz, MCSE+Internet &a...

Form Add-On or feature with explorer (help please)
Good Morning Folks, I am trying to find either an add-in or code to automatically put a file explorer inside an Access form. I would like to browse thru a database table that contains a directory and the file explorer displays the contents (files and folders) in a form window. Other things I would like to do inside of the file explorer is double click word docs to open or move thru the directories inside of the file explorer. Any help would be greatly appreciated. Thank you in advance, Mike ...

transfer emails from my Mac ( mail stamp figure ) to my computer Microsoft Outlook #3
How can I transfer my emails. ...

Add Unit of Measure column to the Purchase Order in RMS Store Ops
Seems like Unit of Measure should be a common column on a purchase order. From what I can see it does look like there is a modified report available for this. It would be nice to have it standard in the software. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http:...

Outlook blocks access
I am trying to sync my large address book in Outlook with my phone using Bluetooth. When I open the connection Outlook tells me an application is trying to open Outlook & allows a maximum of 10minutes to get the information it requires. Unfortunately that's not enough time for my phone to sync all the contacts. Can I disable this feature on a temporary or permanent basis? or can I increase the maximum allowed time currently offered by Outlook. Any help gratefully received Chris Check with your synchronization tool vendor for a newer version that avoids the security prompt....

How do I get Outlook Address Book Contacts into the 'To' window
Hi All You are going to have to bare with me on this, as I can't explain it any other way. In essence, user is using Outlook 2000 (possibly 97 couldn't check at the time) on an XP machine and they have created a number of contacts in the Contacts section of Outlook. Problem is that when they do a new message and click the 'To' button they can't get these contacts to appear in any of the lists that appear, eg Global Address List, All Contacts, etc. They do have a lot of contacts in this window, but these appear to be stored in their Exchange part of the system, as ...

Add timer.tick event handler.
Hello. I see on some components that I can do I.e: addHandler myButton.click, eventHandlerSub But for Timer (is it on System.Timers ?) I cannot handle the tick event. How can I by some code handle the tick event of the timer ? Thanks :) Am 03.04.2010 07:16, schrieb Mr. X.: > Hello. > I see on some components that I can do I.e: > addHandler myButton.click, eventHandlerSub > > But for Timer (is it on System.Timers ?) I cannot handle the tick event. > How can I by some code handle the tick event of the timer ? The System.Windows.Forms.Timer does have a Ti...

blocking domains for incoming email with outlook xp
good morning, is it possible to block entire domains for incoming mail? i mean there are several domains which are constantly being used as spam/junk sender adresses and i'd like to block them off completely or at least tell outlook to move all mails from that particular sender-domain to the junk-mail-folder. is that possible and if, how? is it possible to add more than one sender at a time to the junk-mail-sender-list? thx in advance, malte You are probably better of using a thrid party SPAM FIlter or upgrade to Outlook 2003 as fighting spam with Wizard Rules gets harder and h...

Outlook freezes when starts
I just reformatted my hard drive, installed xp and office 2000, outlook freezes when it starts. I have installed all office updates, please help. ...

Outlook #38
How to add a new adress to your Personal address book? Are you sure you're using a Personal Address Book and not the Outlook Address Book, which is just another view of your Contacts folder? Which version of Outlook are you using? If it's Outlook 98 or Outlook 2000, do you have it configured in Corporate/Workgroup mode or in Internet Mail Only mode? (Quick way to tell -- if your Tools menu has a Services item on it, it's C/W mode; if it has Accounts, it's IMO.) Also, are you connecting to an Exchange server? -- Jocelyn Fiorello MVP - Outlook *** Replies sent to my e-mai...

Email OnLoad Script Email signature
Hi, Would anyone know how to insert a script, so it will insert a body message to a email form? Or if you would know this would work? What I am trying to do is to use the OnLoad function, so it will auto insert a email sigature to all emails. The signature will be same across the organisation for all users. ie. Line 1: Company Name Line: 2 Address Line 3 Telephone. Many thanks! hi This sounds interesting and if you get this working could you please share this with me too. This is something i would need to get done for our organization as well. Thanks in advance Ridhima "SW&...

Using uninstalled fonts in Windows 7
In previous versions of Windows I was able to temporarily use uninstalled fonts by opening the font and minimizing it to the Task Bar. That font would then be available for use in the majority of programs I use: graphics, word processing, etc., by showing up in the list of available fonts. It seems that this feature is no longer available in Windows 7. I open an uninstalled font, minimize it to the Task Bar and it, but it will not show up in the list of fonts available for use in any of the programs in which this previously worked. I really do not want to have to go throug...

Outlook without Exchange Server
I am new to outlook. I am trying to find out if Outlook 2003 can be used with pier-to-pier sertup in a small office with leass than 5 employees. The functionality desired would be to be able to forward and recieve messages, tasks, appointments, share and view calendar etc. I was wondering if outlook can be used within a workgroup in a LAN setup without having exchange server. Thanks, Athiff In news:1ad6001c423e0$2a80b120$a601280a@phx.gbl, Athiff <anonymous@discussions.microsoft.com> wrote: || I am new to outlook. I am trying to find out if Outlook || 2003 can be used with pier-...

Outlook Error #44
A user is getting an saying Error unkown when deleting mail. How do I solve this Thanks a mill ...

Program to synchronize Outlook 2003
Hi, does anybody know of or has a program which synchronizes all email accounts in the background, i. e. while Outlook is running and sitting as an icon in the systray starting the program will send and receive all emails (no intersection with Windows' GUI), and terminate (without notification) when done? Best regards mumdugau Eckhardt Newger <eln@arcor.de> wrote: > does anybody know of or has a program which synchronizes all email > accounts in the background, i. e. while Outlook is running and > sitting as an icon in the systray starting the program will send and >...

Possible To Circumvent Single-Response To Auto-Replies Via Outlook Rules?
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C6638F.C85E8A70 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable In my company, users contact the internal IT support center via several = means, not the least of which is by email. I am trying to set up an = Outlook client to auto-reply to every incoming email with a template = message I previously created. The problem is that when using Outlook = rules to accomplish this, I am limited by the same restrictions in place = when dealing with the 'Out Of Office'...