Link to home
Start Free TrialLog in
Avatar of boeye
boeye

asked on

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)
Avatar of callrs
callrs

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
Ok here's something better that should help:
https://www.experts-exchange.com/questions/21700039/Script-a-silent-Uninstall-of-QuickTime.html     Windows 2000: Script a silent Uninstall of QuickTime
Avatar of boeye

ASKER

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.
Avatar of boeye

ASKER

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.
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
Avatar of boeye

ASKER

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 :)
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
Avatar of boeye

ASKER

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'

ASKER CERTIFIED SOLUTION
Avatar of homemade
homemade

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of boeye

ASKER

Works Perfectly!! Thank you very much!
Great!
Glad I could help ;O)

Brgds Henri
Avatar of boeye

ASKER

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 :)
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