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:{imper sonationLe vel=impers onate}!\\" &_
strComputer & "\root\default:StdRegProv" )
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window s\CurrentV ersion\Uni nstall\Yah oo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP ath,strVal ueName,str UninstallF ullPath
If IsNull(strUninstallFullPat h) Then
' wscript.echo "Uninstall path for app1 is null"
Else
' the following line -y switch suppresses the confirmation question from poping up
strUninstallFullPath=strUn installFul lPath & " -y" '<--- change as needed
WshShell.Run strUninstallFullPath,8,tru e
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)
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{imper
strComputer & "\root\default:StdRegProv"
Set WshShell = WScript.CreateObject("WScr
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP
If IsNull(strUninstallFullPat
' wscript.echo "Uninstall path for app1 is null"
Else
' the following line -y switch suppresses the confirmation question from poping up
strUninstallFullPath=strUn
WshShell.Run strUninstallFullPath,8,tru
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)
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
https://www.experts-exchange.com/questions/21700039/Script-a-silent-Uninstall-of-QuickTime.html Windows 2000: Script a silent Uninstall of QuickTime
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.
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.
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.
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(strUninstallFullPat h) Then
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta llFullPath ),tst)
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left( strUninsta llFullPath ,pos) & "/s " & mid(strUninstallFullPath,p os)
'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=strUn installFul lPath & " -y" '<--- change as needed
WshShell.Run strUninstallFullPath,8,tru e
End If
Good luck;O)
Brgds Henri
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(strUninstallFullPat
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left(
'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=strUn
WshShell.Run strUninstallFullPath,8,tru
End If
Good luck;O)
Brgds Henri
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 :)
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:{imper sonationLe vel=impers onate}!\\" &_
strComputer & "\root\default:StdRegProv" )
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window s\CurrentV ersion\Uni nstall\Yah oo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP ath,strVal ueName,str UninstallF ullPath
If IsNull(strUninstallFullPat h) Then
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta llFullPath ),tst)
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left( strUninsta llFullPath ,pos) & "/s " & mid(strUninstallFullPath,p os)
'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=strUn installFul lPath & " -y" '<--- change as needed
WshShell.Run strUninstallFullPath,8,tru e
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
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{imper
strComputer & "\root\default:StdRegProv"
Set WshShell = WScript.CreateObject("WScr
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP
If IsNull(strUninstallFullPat
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left(
'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=strUn
WshShell.Run strUninstallFullPath,8,tru
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
as posted in your previous comment;O)
If this is not the case then we'll have to rewrite;O)
Brgds Henri
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Works Perfectly!! Thank you very much!
Great!
Glad I could help ;O)
Brgds Henri
Glad I could help ;O)
Brgds Henri
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:{imper sonationLe vel=impers onate}!\\" &_
strComputer & "\root\default:StdRegProv" )
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window s\CurrentV ersion\Uni nstall\Yah oo! Messenger" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP ath,strVal ueName,str UninstallF ullPath
If IsNull(strUninstallFullPat h) Then
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta llFullPath ),tst)
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left( strUninsta llFullPath ,pos) & "/s " & mid(strUninstallFullPath,p os)
End If
WshShell.Run strUninstallFullPath,8,tru e
End If
' Uninstall second application...
strKeyPath = "SOFTWARE\Microsoft\Window s\CurrentV ersion\Uni nstall\Yah oo! Internet Mail" '<--- change as needed
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP ath,strVal ueName,str UninstallF ullPath
If IsNull(strUninstallFullPat h) Then
' wscript.echo "Uninstall path for app1 is null"
Else
strUninstallFullPath=strUn installFul lPath & " -y"
WshShell.Run strUninstallFullPath,8,tru e
End If
Set WshShell = Nothing
Set oReg = Nothing
Thanks in advance :)
const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set oReg = GetObject("winmgmts:{imper
strComputer & "\root\default:StdRegProv"
Set WshShell = WScript.CreateObject("WScr
' Uninstall first application...
strKeyPath = "SOFTWARE\Microsoft\Window
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP
If IsNull(strUninstallFullPat
' wscript.echo "Uninstall path for app1 is null"
Else
tst="unwise.exe"
pos=instr(lcase(strUninsta
if pos>0 then
'found unwise.exe
pos=pos+len(tst)
strUninstallFullPath=left(
End If
WshShell.Run strUninstallFullPath,8,tru
End If
' Uninstall second application...
strKeyPath = "SOFTWARE\Microsoft\Window
strValueName = "UninstallString"
oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyP
If IsNull(strUninstallFullPat
' wscript.echo "Uninstall path for app1 is null"
Else
strUninstallFullPath=strUn
WshShell.Run strUninstallFullPath,8,tru
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=strUn installFul lPath & " -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
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=strUn
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
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=imper
Set colSoftware = objWMIService.ExecQuery _
("Select * from Win32_Product Where Name = 'Personnel database'")
For Each objSoftware in colSoftware
objSoftware.Uninstall()
Next