Solved

VBScript to uninstall Yahoo Messenger

Posted on 2006-06-13
13
1,059 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
If you don't know how to downgrade, my instructions below should be helpful.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 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

13 Experts available now in Live!

Get 1:1 Help Now