Solved

VBScript to uninstall Yahoo Messenger

Posted on 2006-06-13
13
1,062 Views
Last Modified: 2012-05-05
Hello Experts. I'm definitely not a VBScript guy but I was able to pull together some code that does most of what I want. I'm trying to have it uninstall Yahoo Messenger without prompting during the uninstall process. I have the tried the -y, -s and other tags but it still prompts. Here is the code I have so far:

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
           strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("WScript.Shell")

' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yahoo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strUninstallFullPath
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"
Else
   ' the following line -y switch suppresses the confirmation question from poping up
   strUninstallFullPath=strUninstallFullPath & " -y"                               '<--- change as needed
   WshShell.Run strUninstallFullPath,8,true
End If


Set WshShell = Nothing
Set oReg = Nothing


If you are not opposed to it try installing Yahoo messenger and then run this script and you will see what I'm talking about. Any suggestions would be most helpful.

Thank you,

Brad

P.S. I'm not opposed to trying another method of removal if you have one. (Win 2k AD, XP workstations)
0
Comment
Question by:boeye
  • 6
  • 5
  • 2
13 Comments
 
LVL 30

Expert Comment

by:callrs
ID: 16897158
http://www.microsoft.com/technet/scriptcenter/scripts/apps/user/usapvb01.mspx     Delete Software
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Personnel database'")

For Each objSoftware in colSoftware
    objSoftware.Uninstall()
Next
0
 
LVL 30

Expert Comment

by:callrs
ID: 16897267
Ok here's something better that should help:
http://www.experts-exchange.com/Operating_Systems/Win2000/Q_21700039.html     Windows 2000: Script a silent Uninstall of QuickTime
0
 

Author Comment

by:boeye
ID: 16897344
callrs,

Thanks for the quick response. I'm not sure either will do the trick and again I'm not much of a programmer so without code relating directly to my scenario I'm pretty lost. At this point the script I have written launches the uninstall but it gets to a prompt screen with the following uninstall options: Automatic, Repair and Cancel. I would like this uninstall to run silent and not give the users any options.

Thanks again.
0
 

Author Comment

by:boeye
ID: 16897438
I figured out if I launch the uninstall command "C:\PROGRA~1\Yahoo!\MESSEN~1\UNWISE.EXE C:\PROGRA~1\Yahoo!\MESSEN~1\INSTALL.LOG" and I'm able to put the /s switch after the unwise.exe command it will uninstall without prompting. Currently the VBScript I have puts the command and the end after "..Install.log" which does no good. Is there a way to accomplish this in the VBScript?

Thanks.
0
 
LVL 2

Expert Comment

by:homemade
ID: 16898466
The uninstall command according to your script is in the variable strUninstallFullPath

The trick is to find the space between the first and the second part.
Let vb search for the sustring unwise.exe and insert /s behing like this:

.....
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"
Else

    tst="unwise.exe"
    pos=instr(lcase(strUninstallFullPath),tst)
   if pos>0 then
      'found unwise.exe
      pos=pos+len(tst)
      strUninstallFullPath=left(strUninstallFullPath,pos) & "/s " & mid(strUninstallFullPath,pos)

      'I have commented out the following as your last post indicated that the -y part should be skipped
      ' if I have misunderstood you should enable it again
      ' strUninstallFullPath=strUninstallFullPath & " -y"                               '<--- change as needed

   WshShell.Run strUninstallFullPath,8,true
End If

Good luck;O)
Brgds Henri
0
 

Author Comment

by:boeye
ID: 16898513
That sounds great. Would this code take the place of the one I had or does it need to be added? If it needs to be added could you put it together with the existing code for me?
My VB skills are minimal at best.

Thanks :)
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:homemade
ID: 16898552
This code should just replace the part starting with if in your original code, the full code will then be:


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
           strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("WScript.Shell")

' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yahoo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strUninstallFullPath
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"
Else

    tst="unwise.exe"
    pos=instr(lcase(strUninstallFullPath),tst)
   if pos>0 then
      'found unwise.exe
      pos=pos+len(tst)
      strUninstallFullPath=left(strUninstallFullPath,pos) & "/s " & mid(strUninstallFullPath,pos)

      'I have commented out the following as your last post indicated that the -y part should be skipped
      ' if I have misunderstood you should enable it again
      ' strUninstallFullPath=strUninstallFullPath & " -y"                               '<--- change as needed

   WshShell.Run strUninstallFullPath,8,true
End If

Set WshShell = Nothing
Set oReg = Nothing





All this is assuming that your original code brings you the line
"C:\PROGRA~1\Yahoo!\MESSEN~1\UNWISE.EXE C:\PROGRA~1\Yahoo!\MESSEN~1\INSTALL.LOG"
as posted in your previous comment;O)
If this is not the case then we'll have to rewrite;O)
Brgds Henri
0
 

Author Comment

by:boeye
ID: 16898726
Thanks so much. I receive the following error when trying to run the above script. It errors out after the last line saying Error: Expected 'End'

0
 
LVL 2

Accepted Solution

by:
homemade earned 500 total points
ID: 16898757
Ooops, sorry ;)
Forgot end if,
look for ************ forgotten end if ****** in the code....
HM


const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
           strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("WScript.Shell")

' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yahoo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strUninstallFullPath
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"
Else

    tst="unwise.exe"
    pos=instr(lcase(strUninstallFullPath),tst)
   if pos>0 then
      'found unwise.exe
      pos=pos+len(tst)
      strUninstallFullPath=left(strUninstallFullPath,pos) & "/s " & mid(strUninstallFullPath,pos)

      'I have commented out the following as your last post indicated that the -y part should be skipped
      ' if I have misunderstood you should enable it again
      ' strUninstallFullPath=strUninstallFullPath & " -y"                               '<--- change as needed

   End if   '************ forgotten end if ******

   WshShell.Run strUninstallFullPath,8,true

End If

Set WshShell = Nothing
Set oReg = Nothing
0
 

Author Comment

by:boeye
ID: 16904513
Works Perfectly!! Thank you very much!
0
 
LVL 2

Expert Comment

by:homemade
ID: 16904854
Great!
Glad I could help ;O)

Brgds Henri
0
 

Author Comment

by:boeye
ID: 16904898
Could I ask one more favor? I'm trying to add an additional yahoo program to be uninstalled into the script and just want to verify if the code is correct. In this case the second application can install directly from the uninstall string without needing any additional /s or other strings.

const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
           strComputer & "\root\default:StdRegProv")
Set WshShell = WScript.CreateObject("WScript.Shell")

' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yahoo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strUninstallFullPath
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"

Else
   tst="unwise.exe"
   pos=instr(lcase(strUninstallFullPath),tst)
  if pos>0 then
   'found unwise.exe
   pos=pos+len(tst)
   strUninstallFullPath=left(strUninstallFullPath,pos) & "/s " & mid(strUninstallFullPath,pos)  
  End If                      
 
 WshShell.Run strUninstallFullPath,8,true

End If
 
' Uninstall second application...
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Yahoo! Internet Mail" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strUninstallFullPath
If IsNull(strUninstallFullPath) Then
   ' wscript.echo "Uninstall path for app1 is null"

Else
   strUninstallFullPath=strUninstallFullPath & " -y"
   WshShell.Run strUninstallFullPath,8,true
End If



Set WshShell = Nothing
Set oReg = Nothing


Thanks in advance :)
0
 
LVL 2

Expert Comment

by:homemade
ID: 16906808
Looks good to me.

Seems to me that this will run the uninstall command found in the registry for Yahoo! Internet Mail also.
It will also add a -y at the end of the command,
if this is unwanted the line

strUninstallFullPath=strUninstallFullPath & " -y"

can be commented out.


If you are having problems uninstalling Yahoo Internet Mail, this link has a solution that seem to work
(somewhere down there, posting 9 I think)
http://www.computing.net/windows2000/wwwboard/forum/58365.html

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now