VBScript to uninstall Yahoo Messenger

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)
boeyeAsked:
Who is Participating?
 
homemadeCommented:
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
 
callrsCommented:
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
 
callrsCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
boeyeAuthor Commented:
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
 
boeyeAuthor Commented:
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
 
homemadeCommented:
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
 
boeyeAuthor Commented:
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
 
homemadeCommented:
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
 
boeyeAuthor Commented:
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
 
boeyeAuthor Commented:
Works Perfectly!! Thank you very much!
0
 
homemadeCommented:
Great!
Glad I could help ;O)

Brgds Henri
0
 
boeyeAuthor Commented:
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
 
homemadeCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.