One script that can be used to unstall many softwares at once. As a login script.

bsharath
bsharath used Ask the Experts™
on
Hi,

One script that can be used to unstall many softwares at once. As a login script.
Like in the script with few changes and mention the list as
VLC payer,iTunes,Winrar. The script when run removes all the sftwares if available and then record which software was removed with the machine name and time in the UNC log.

Can anyone help with a script please.

REgards
Sharath
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Read HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall registry key. You'll have to traverse this key. For each child node, you will have to read DisplayName and if the string is the program name you want to uninstall then read UninstallString key and run that as a shell command.

I hope this helps!!!  
Most Valuable Expert 2012
Top Expert 2014

Commented:
This code will do the above, and list all of the software installed on a system, so we can just use this to find the UninstallString for a product and remove it.

It should run under a StartUp script though, so that it has rights to uninstall the software.

I will work on providing the uninstall method soon...

Regards,

Rob.
If LCase(Right(Wscript.FullName, 11)) = "wscript.exe" Then
    strPath = Wscript.ScriptFullName
    strCommand = "%comspec% /c cscript  """ & strPath & """"
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run(strCommand), 1, True
    Wscript.Quit
End If
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\"&_ 
    strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
WScript.Echo "Subkeys under " _
    & "HKEY_LOCAL_MACHINE\SYSTEM\Software\Microsoft\Windows\CurrentVersion\Uninstall"
For Each subkey In arrSubKeys
    WScript.Echo subkey
    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subKey, "DisplayName", strDisplayName
    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subKey, "Publisher", strPublisher
    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & subKey, "DisplayVersion", strDisplayVersion
    If Not IsNull(strDisplayName) Then
       WScript.Echo vbTab & "Display Name: " & strDisplayName
    End If 
    If Not IsNull(strDisplayName) Then
       WScript.Echo vbTab & "Publisher: " & strPublisher
    End If 
    If Not IsNull(strDisplayName) Then
       WScript.Echo vbTab & "Display Version: " & strDisplayVersion
    End If 
Next

Open in new window

Author

Commented:
Thanks Rob...Do you mean it will dump all the uninstall strigs of all machines into a file . I need to run this as a startup script in the AD
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Most Valuable Expert 2012
Top Expert 2014

Commented:
No, the code above will only list installed software, nothing more.  I will work on it to uninstall specific software.

Regards,

Rob.
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can try this manually while logged in as an admin.  When you apply it as a Startup script it will run with System rights, so should work fine if Admin works.

Change

arrSoftwareToUninstall = Array( _
      "Compatibility", _
      "Google", _
      "Citrix" _
      )

to specify the software names. It performs a partial match of the name.

Regards,

Rob.
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				'WScript.Echo strUninstallString & " /Q"
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Rob thank U
Should i use just the latest ione or even the first code?

Author

Commented:
I get  this
11/4/2009 11:15:06 AM: IN-DSM - Silent uninstall unknown for 7-zip 4.65
11/4/2009 11:15:06 AM: IN-DSM - Silent uninstall unknown for webex
Most Valuable Expert 2012
Top Expert 2014

Commented:
Can you change this:
                        objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName

to this
                        objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " --- " & strUninstallString

and run it again? Then I can have a look at the uninstall commands.  My feeling is that you need this silent, and I'm not sure what the silent switches for those would be...

Regards,

Rob.

Author

Commented:
Here is the details

11/4/2009 11:35:41 AM: IN-ICT-DSM - Silent uninstall unknown for 7-zip 4.65 --- "C:\7\Uninstall.exe"
11/4/2009 11:35:41 AM: IN-ICT-DSM - Silent uninstall unknown for webex --- C:\PROGRA~1\WebEx\atcliun.exe
Most Valuable Expert 2012
Top Expert 2014

Commented:
I cannot find any silent uninstall options for WebEx. I think this is only possible to uninstall with a manual prompt.  I will look into 7-zip....

Rob.

Author

Commented:
For webex this is the uninstall file
atcliun.exe
When run it says uninstall
Most Valuable Expert 2012
Top Expert 2014

Commented:
atcliun.exe has no command line parameters, it cannot be uninstalled silently, it must be done manually.

7Zip supports the /S parameter, so this should now uninstall 7Zip as well.

Regards,

Rob.
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString & " /S"
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
I get this

---------------------------
Windows Script Host
---------------------------
Script:      E:\Uninstall_Any_Software.vbs
Line:      63
Char:      5
Error:      Object required: 'objShell'
Code:      800A01A8
Source:       Microsoft VBScript runtime error

---------------------------
OK  
---------------------------

Rob i will be using this for varios softwares. Is there anything i need to change. If there is a Silent Uninstall possible then is there something to be changed in the code
Most Valuable Expert 2012
Top Expert 2014

Commented:
Oh, forgot the Shell object! LOL!

Rob.
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString & " /S"
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Rob for each software should the "uninstall.exe" be there to work?
I am trying to uninstall Nokia any software replated to it...

Author

Commented:
I am trying to uninstall Google talk

C:\Program Files\Google\Google Talk\uninstall.exe
I get this in the log
11/10/2009 1:34:43 PM: I-DSM - Silent uninstall unknown for google talk (remove only)
Most Valuable Expert 2012
Top Expert 2014

Commented:
Most Nokia software uses MSIExec to install, so the uninstall should do the same, and should work OK.

Google Talk also supports the /S for silent uninstall so if you change this
                  ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Then

to this
                  ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Or InStr(LCase(strDisplayName), "google talk") > 0 Then

it should work for Google Talk as well.

The reason you see
Silent uninstall unknown for <appname>

is because I don't want to automatically *try* to remove application that are not going to be silent.  Any uninstall that requires a manual click will not work as an automatic script, and must be uninstalled manually.  For each program that has that, you can do a bit of research (for Google Talk:http://www.appdeploy.com/packages/detail.asp?id=755) that might suggest how to silently uninstall a specific program, and we can add that to the script.

Regards,

Rob.

Author

Commented:
Thanks Rob...Does that mean that we need to add each app into this line too other than the names in the top most of the script

       ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Or InStr(LCase(strDisplayName), "google talk") > 0 Then
Most Valuable Expert 2012
Top Expert 2014

Commented:
Yes, but *only* if you originally get "Silent uninstall unknown for <appname>" and you know that that application supports the /S switch for uninistall.  If you find out that it uses another switch, like maybe /Q, then you need to add

                  ElseIf InStr(LCase(strDisplayName), "another_app") > 0 Then
                        strUninstallString = strUninstallString & " /Q"
                        'WScript.Echo strUninstallString & " /Q"

underneath it.

Rob.

Author

Commented:
Is there any wat that we can mention just the app names in the top and the script tries /S or /Q for each uninstall.
If /S fails then /Q

Why i ask is say for google
we have
Google talk
Google earth
Google tool bar
and many more

if we can mention just "Google" then all softwares related to google if uninstalled would be very very useful
Most Valuable Expert 2012
Top Expert 2014

Commented:
Well Google Earth uses an MSIExec uninstall, so the script should already do that one silently.

I wouldn't want to *try* using a switch, because if the switch doesn't work, the uninstall gets stuck waiting for some user input, and cannot be stopped.  So it really would be trial and error per application to see whether the script can already handle it, and if not, research whether there is a possible silent uninstall, and plug it into the script.

Some applications (like WebEx) don't have a silent uninstall at all, and therefore would cause the script to hang if it *tried* to uninstall it automatically.

Regards,

Rob.

Author

Commented:
Ok... What happens when an application like google earth has a silent switch but fails on a machine. Will it record and skip to another machine.
Most Valuable Expert 2012
Top Expert 2014

Commented:
Your question about uninstalling VLC can also be done with this script if you change
                  ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Or InStr(LCase(strDisplayName), "google talk") > 0 Then

to
                  ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Or InStr(LCase(strDisplayName), "google talk") > 0 Or InStr(LCase(strDisplayName), "vlc") > 0 Then

Regards,

Rob.
Most Valuable Expert 2012
Top Expert 2014

Commented:
>> What happens when an application like google earth has a silent switch but fails on a machine. Will it record and skip to another machine.

Yes, if the app supports a silent install, when it fails, it will return an error code to the script, and the script will say the uninstall failed, and it will continue.

Rob.

Author

Commented:
Ok thanks...
Can you post the link there.So i can close it

Please check if the below code is righ.

I have 2 rows commented and mentioned a question
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
 
'If i need to add 4 more apps with which gets uninstalled with the /S then what should the below line look as
 
			        ElseIf InStr(LCase(strDisplayName), "7-zip") > 0 Or InStr(LCase(strDisplayName), "google talk") > 0 Then
 
 
'If i need to add 4 more apps with which gets uninstalled with the /Q then what should the below line look as
 ElseIf InStr(LCase(strDisplayName), "another_app") > 0 Then
                        strUninstallString = strUninstallString & " /Q"
                        'WScript.Echo strUninstallString & " /Q"
 
 
 
 
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString & " /S"
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Rob but for the vlc player. If found needs to stop the sophos antivirus service and then uninstall. As the antivirus stops the uninstall when the service is live
Stop > Uninstall > then Start
Most Valuable Expert 2012
Top Expert 2014

Commented:
>> the vlc player. If found needs to stop the sophos antivirus service and then uninstall
Ah, in that case, we will leave that in the other question....I'll have a look.

For adding more application names, I've re-ordered the code slightly, to make it easier to understand, and added instructions just above each code block.

Regards,

Rob.
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("google talk")) > 0 _
 	        	Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
	 			InStr(LCase(strDisplayName), LCase("another_app")) > 0 _
 				Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Thank you Rob

If the 3rd or 2nd application needs to be added should it be as this

How should the 3rd line be in the /S part and the 2nd app be in the 2nd app in /Q...
As adding additional lines would help for me...To just change the name...
Most Valuable Expert 2012
Top Expert 2014

Commented:
Well, for one app you would have this:
               ElseIf _
                     InStr(LCase(strDisplayName), LCase("google talk")) > 0 _
                     Then

which has no "Or" in it.  For two, you would have this
               ElseIf _
                     InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talk")) > 0 _
                     Then

where the top one has "Or" before the underscore, and the last one does not.
For three, you would have
               ElseIf _
                     InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("another_app")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talk")) > 0 _
                     Then

where the top two have "Or" and only the last one does not.

For four:
               ElseIf _
                     InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("another_app")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("another_app2")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talk")) > 0 _
                     Then

where all but the last InStr lines have "Or".  I hope you can see the pattern there.  To have four, I would just copy the "7-zip" line, paste it directly underneath the existing 7-zip line, and change the app name.

Regards,

Rob.

Author

Commented:
Perfect how will the /Q pattern be

Most Valuable Expert 2012
Top Expert 2014

Commented:
Exactly the same.  The only difference is the applicatoin name, because one might use /S, which is appended after the Then word, and one might use /Q, which is appended after that statement's Then word, if a match is found.

Rob.

Author

Commented:
Thanks Rob...If i leave the data blank will it skip to next

 InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("")) > 0 Or _

Author

Commented:
One more question should the identical software names be mentioned even here

arrSoftwareToUninstall = Array( _
      "Compatibility", _
      "Google", _
      "Citrix" _
      )
Most Valuable Expert 2012
Top Expert 2014

Commented:
>> ...If i leave the data blank will it skip to next

No, don't leave it blank, because that would match every software, and try adding /S or /Q to it.

You would be better off making it something completely weird, like
               ElseIf _
                     InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("never_an_applicatoin_with_this_name")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("an_applicatoin_that_does_not_exist")) > 0 _
                     Then


>> should the identical software names be mentioned even here

Yes, the software that you want to try to uninstall MUST be in the arrSoftwareToUninstall array.

Regards,

Rob.

Author

Commented:
Sorry to drag this

I have these 3 lines

 InStr(LCase(strDisplayName), LCase("Windows PowerShell")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("NetworkSleuth")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscan Evaluation")) > 0 Or _

All the 3 softwares are there
When run i get a popup asking me to click yes/No for the last 2 softwares and for Windows Powershell i get nothing

In the log i get

11/11/2009 10:31:08 AM: IDSM - Failed to uninstall zipscan evaluation 2.2c
11/11/2009 10:31:09 AM: IDSM - Failed to uninstall networksleuth 2.0.2
Most Valuable Expert 2012
Top Expert 2014

Commented:
If you still get a popup asking for the product to be uninstalled, then that application probably does not support a silent uninstall.

I did a Google search for
networksleuth silent uninstall

and it looks like that program uses
"%ProgramFiles%\Nsasoft\NetworkSleuth\unins000.exe" /SILENT

so that's a different switch to use, which I've added to the code below. I'm not sure about ZipScan though.

Regards,

Rob.
strLogFile = "\\server\share\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Compatibility", _
	"Google", _
	"Citrix" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("7-zip")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("google talk")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("an_applicatoin_that_does_not_exist")) > 0 _
 	        	Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("never_an_application_with_this_name")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("an_application_that_does_not_exist")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("another_app")) > 0 _
 				Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("networksleuth")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("an_application_that_does_not_exist")) > 0 Or _
 	        	InStr(LCase(strDisplayName), LCase("another_app")) > 0 _
 				Then
				strUninstallString = strUninstallString & " /SILENT"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			If boolUnknown = True Then
				Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
				objFile.Close
			Else
				intReturn = objShell.Run(strUninstallString, 1, True)
				If intReturn = 0 Then
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
					objFile.Close
				Else
					Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
					objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
					objFile.Close
				End If
			End If
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Thanks Rob..
If i need to find if there is a Silent switch and if yes which. then how can i find.
Will all microsoft Installation have a Uninstall silent switch.?
Most Valuable Expert 2012
Top Expert 2014

Commented:
All Microsoft installations should use MSIExec, which is already included into the script, so you don't need to worry about that. Anything that uses MSIExec supports "/Quiet /NoRestart", and anything that uninstalls with dpinst.exe supports the /Q switch, which the script already checks.

If the log file tells you that the silient uninstall is unknown, then I would search AppDeploy.com and Google "<app name> silent uninstall" and see if anything comes up.

The other option is when the log tells you
"Silent uninstall unknown for <appname> with Uninstall string <UninstallString>"

you can copy the <UninstallString> to a command line, and add /? to it.

For example, if it said
"Silent uninstall unknown for <appname> with Uninstall string C:\MyApp\Uninst.exe"

then at a command prompt, run
C:\MyApp\Uninst.exe /?

and if it shows you any usage switches, you can try those.  As I said before, not all application support any switches though.

Basically, first run the script for a specific application in arrSoftwareToUninstall to see it knows how to uninstall then, then check the log.

Regards,

Rob.

Author

Commented:
Thanks now i am very clear
For 1 i get this

11/11/2009 11:42:06 AM: ISM - Failed to uninstall sophos autoupdate with Uninstall string of MsiExec.exe /X{15C418EB-7675-42be-B2B3-281952DA014D} /quiet /norestart
In such cases

Author

Commented:
When i try uninstalling Office i get this

install unknown for microsoft office enterprise 2007 with Uninstall string of "C:\Program Files\Common Files\Microsoft Shared\OFFICE12\Office Setup Controller\setup.exe" /uninstall ENTERPRISE /dll OSETUP.DLL
11/11/2009 12:03:15 PM: DSM - Uninstalled microsoft office access mui (english) 2007
11/11/2009 12:03:19 PM: DSM - Uninstalled microsoft office excel mui (english) 2007
11/11/2009 12:03:21 PM: DSM - Uninstalled microsoft office powerpoint mui (english) 2007
11/11/2009 12:03:27 PM: DSM - Uninstalled microsoft office publisher mui (english) 2007
11/11/2009 12:03:32 PM: DSM - Uninstalled microsoft office outlook mui (english) 2007
11/11/2009 12:03:36 PM: DSM - Uninstalled microsoft office word mui (english) 2007
11/11/2009 12:03:38 PM: DSM - Uninstalled microsoft office proof (english) 2007
11/11/2009 12:03:40 PM: DSM - Uninstalled microsoft office proof (french) 2007
11/11/2009 12:03:42 PM: DSM - Uninstalled microsoft office proof (spanish) 2007
11/11/2009 12:03:42 PM: DSM - Uninstalled microsoft office proofing (english) 2007
11/11/2009 12:03:49 PM: DSM - Failed to uninstall microsoft office enterprise 2007 with Uninstall string of MsiExec.exe /X{90120000-0030-0000-0000-0000000FF1CE} /quiet /norestart

And this displays on screen

---------------------------
Setup Controller Command-Line Help
---------------------------
/? - Display this command-line help

/admin - Launch the Office Customization Tool

/adminfile <admin file> - Specify a customization patch or folder containing a customization patch

/config <config file> - Specify a config.xml file

/modify <product ID> - Enter Maintenance Mode for a product

/repair <product ID> - Repair a product

/uninstall <product ID> - Uninstall a product
---------------------------
OK  
---------------------------

Author

Commented:
For some machines i get too.
---------------------------
Windows Script Host
---------------------------
Script:      E:\Uninstall_Any_Software.vbs
Line:      92
Char:      5
Error:      The system cannot find the file specified.
Code:      80070002
Source:       (null)

---------------------------
OK  
---------------------------

Author

Commented:
For vlc if the path is like this it gets uninstalled

uninstall.exe /S /NCRC

Author

Commented:
Rob attached the few softwares i am trying to uninstall. With uninstall strings
They all have different strings
Is there some other way to ease such installations.

Uninstall.xls
Most Valuable Expert 2012
Top Expert 2014

Commented:
For the line 92 error, change this section:

                  If boolUnknown = True Then
                        Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                        objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
                        objFile.Close
                  Else
                        intReturn = objShell.Run(strUninstallString, 1, True)
                        If intReturn = 0 Then
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
                              objFile.Close
                        Else
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
                              objFile.Close
                        End If
                  End If



to this:

                  If boolUnknown = True Then
                        On Error Resume Next
                        Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                        If Err.Number = 0 Then
                              On Error GoTo 0
                              objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
                              objFile.Close
                        Else
                              Err.Clear
                              On Error GoTo 0
                        End If
                  Else
                        intReturn = objShell.Run(strUninstallString, 1, True)
                        If intReturn = 0 Then
                              On Error Resume Next
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              If Err.Number = 0 Then
                                    On Erro GoTo 0
                                    objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
                                    objFile.Close
                              Else
                                    Err.Clear
                                    On Error GoTo 0
                              End If
                        Else
                              On Error Resume Next
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              If Err.Number = 0 Then
                                    On Error GoTo 0
                                    objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
                                    objFile.Close
                              Else
                                    Err.Clear
                                    On Error GoTo 0
                              End If
                        End If
                  End If



For "Microsoft Office 2007 Enterprise", from here:
http://technet.microsoft.com/en-us/library/cc982159.aspx
it says you must modify the Config.xml file for the product and set the Display element's Level attribute to "none" (Display Level="none").
Therefore, this script will not be able to remove that.


For VLC, to supply the /S /NCRC switches, add this

                  ElseIf _
                     InStr(LCase(strDisplayName), LCase("vlc")) > 0 _
                         Then
                        strUninstallString = strUninstallString & " /S /NCRC"
                        'WScript.Echo strUninstallString


As I said, some product do not even *support* a silent uninstall, so you won't be able to use this to uninstall them, and must do them manually.


Regards,

Rob.

Author

Commented:
Hi Rob i get this

---------------------------
Windows Script Host
---------------------------
Script:      E:\Uninstall_Any_Software.vbs
Line:      90
Char:      1
Error:      Expected 'Wend'
Code:      800A03FA
Source:       Microsoft VBScript compilation error

---------------------------
OK  
---------------------------

Here is the full code i have after the change..

Did you have a look at the attachment here
ID: 25795576
As every product has a uninstall string will it uninstall all in the cirrent code that you have given me....

strLogFile = "\\i-dsm\Logs\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
		"Vlcfsdf", _
        "Google Talk3" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("sdfsdf")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google tgalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Microsoft Officefdhg")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googledfg tralk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan vlc ffmedia player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google tqalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscadfgn Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googldfge talk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan sdfvlc media player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google txalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscanx Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talrk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /SILENT"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If
			
 
 
ElseIf _
                     InStr(LCase(strDisplayName), LCase("vlc")) > 0 _
                         Then
                        strUninstallString = strUninstallString & " /S /NCRC"
                        'WScript.Echo strUninstallString
 
 
 
 If boolUnknown = True Then
                        On Error Resume Next
                        Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                        If Err.Number = 0 Then
                              On Error GoTo 0
                              objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
                              objFile.Close
                        Else
                              Err.Clear
                              On Error GoTo 0
                        End If
                  Else
                        intReturn = objShell.Run(strUninstallString, 1, True)
                        If intReturn = 0 Then
                              On Error Resume Next
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              If Err.Number = 0 Then
                                    On Erro GoTo 0
                                    objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
                                    objFile.Close
                              Else
                                    Err.Clear
                                    On Error GoTo 0
                              End If
                        Else
                              On Error Resume Next
                              Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
                              If Err.Number = 0 Then
                                    On Error GoTo 0
                                    objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
                                    objFile.Close
                              Else
                                    Err.Clear
                                    On Error GoTo 0
                              End If
                        End If
                  End If
 
 
 
 
 
 
 
 
 
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Most Valuable Expert 2012
Top Expert 2014

Commented:
Try this code.

If you know which switches those applications use to perform a silent uninstall, then you can plug their names into the relevat ElseIf statement that would add that particular switch.

Regards.

Rob.
strLogFile = "\\i-dsm\Logs\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Vlcfsdf", _
	"Google Talk3" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("sdfsdf")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google tgalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Microsoft Officefdhg")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googledfg tralk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan vlc ffmedia player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google tqalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscadfgn Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googldfge talk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan sdfvlc media player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google txalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscanx Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talrk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /SILENT"
				'WScript.Echo strUninstallString
			ElseIf _
				InStr(LCase(strDisplayName), LCase("vlc")) > 0 _
					Then
				strUninstallString = strUninstallString & " /S /NCRC"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If 
 
			If boolUnknown = True Then
			      On Error Resume Next
			      Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			      If Err.Number = 0 Then
			            On Error GoTo 0
			            objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
			            objFile.Close
			      Else
			            Err.Clear
			            On Error GoTo 0
			      End If
			Else
			      intReturn = objShell.Run(strUninstallString, 1, True)
			      If intReturn = 0 Then
			            On Error Resume Next
			            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			            If Err.Number = 0 Then
			                  On Erro GoTo 0
			                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
			                  objFile.Close
			            Else
			                  Err.Clear
			                  On Error GoTo 0
			            End If
			      Else
			            On Error Resume Next
			            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			            If Err.Number = 0 Then
			                  On Error GoTo 0
			                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
			                  objFile.Close
			            Else
			                  Err.Clear
			                  On Error GoTo 0
			            End If
			      End If
			End If
 
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Rob just to confirm..
Now if the uninstall works with
/S
/Q
/S /NCRC
/Silent
Or any others too
Most Valuable Expert 2012
Top Expert 2014

Commented:
Yes, if the application supports, say the /Q switch, add the name into an InStr line above this
                        strUninstallString = strUninstallString & " /Q"

and it will use that switch.

Rob.

Author

Commented:
I get this now

---------------------------
Windows Script Host
---------------------------
Script:      E:\Uninstall_Any_Software.vbs
Line:      31
Char:      3
Error:      Multiple-step operation generated errors. Check each status value.
Code:      80040E21
Source:       Microsoft Cursor Engine

---------------------------
OK  
---------------------------
Most Valuable Expert 2012
Top Expert 2014

Commented:
Strange.....try this.
strLogFile = "\\i-dsm\Logs\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Vlcfsdf", _
	"Google Talk3" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("sdfsdf")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google tgalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Microsoft Officefdhg")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googledfg tralk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan vlc ffmedia player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google tqalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscadfgn Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googldfge talk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan sdfvlc media player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google txalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscanx Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talrk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /SILENT"
				'WScript.Echo strUninstallString
			ElseIf _
				InStr(LCase(strDisplayName), LCase("vlc")) > 0 _
					Then
				strUninstallString = strUninstallString & " /S /NCRC"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If 
 
			If boolUnknown = True Then
			      On Error Resume Next
			      Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			      If Err.Number = 0 Then
			            On Error GoTo 0
			            objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
			            objFile.Close
			      Else
			            Err.Clear
			            On Error GoTo 0
			      End If
			Else
			      intReturn = objShell.Run(strUninstallString, 1, True)
			      If intReturn = 0 Then
			            On Error Resume Next
			            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			            If Err.Number = 0 Then
			                  On Error GoTo 0
			                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
			                  objFile.Close
			            Else
			                  Err.Clear
			                  On Error GoTo 0
			            End If
			      Else
			            On Error Resume Next
			            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			            If Err.Number = 0 Then
			                  On Error GoTo 0
			                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
			                  objFile.Close
			            Else
			                  Err.Clear
			                  On Error GoTo 0
			            End If
			      End If
			End If
 
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
I get this

---------------------------
Windows Script Host
---------------------------
Script:      E:\Uninstall_Any_Software.vbs
Line:      105
Char:      10
Error:      The system cannot find the file specified.
Code:      80070002
Source:       (null)

---------------------------
OK  
---------------------------

Author

Commented:
Can you add a statement for
/Uninstall also
Most Valuable Expert 2012
Top Expert 2014
Commented:
OK, this also has the /UNINSTALL switch.

Rob.
strLogFile = "\\i-dsm\Logs\UninstallationLog.txt"
Set objNetwork = CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
 
arrSoftwareToUninstall = Array( _
	"Vlcfsdf", _
	"Google Talk3" _
	)
 
Set objShell = CreateObject("WScript.Shell")
Const adVarChar = 200
Const MaxCharacters = 255
Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "DisplayName", adVarChar, MaxCharacters
DataList.Fields.Append "UninstallString", adVarChar, MaxCharacters
DataList.Open
 
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows\CurrentVersion\Uninstall"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
For Each strSubkey In arrSubKeys
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "DisplayName", strDisplayName
	objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubKey, "UninstallString", strUninstallString
	If IsNull(strDisplayName) = True Then strDisplayName = ""
	If IsNull(strUninstallString) = True Then strUninstallString = ""
	If strDisplayName <> "" Then
		DataList.AddNew
		DataList("DisplayName") = LCase(strDisplayName)
		DataList("UninstallString") = strUninstallString
		DataList.Update
	End If
Next
 
For Each strSoftware In arrSoftwareToUninstall
	DataList.Filter = "DisplayName LIKE '*" & LCase(strSoftware) & "*'"
	If Not DataList.EOF Then
		DataList.MoveFirst
		While Not DataList.EOF
			strDisplayName = DataList("DisplayName")
			strUninstallString = DataList("UninstallString")
			boolUnknown = False
			If InStr(LCase(strUninstallString), "msiexec") > 0 Or InStr(LCase(strUninstallString), "spuninst") > 0 Then
				strUninstallString = strUninstallString & " /quiet /norestart"
				'WScript.Echo strUninstallString & " /quiet /norestart"
			ElseIf InStr(LCase(strUninstallString), "dpinst") > 0 Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString & " /Q"
			' To add more apps with the /S switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 	        ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("sdfsdf")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google tgalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Microsoft Officefdhg")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googledfg tralk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /S"
				'WScript.Echo strUninstallString
			' To add more apps with the /Q switch, copy the InStr line and change
			' the name in quotes to match the display name of the application
			' It only has to be part of the name, but should be unique to that application
			' Only the *last* InStry line does NOT have the word "Or" before the underscore
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan vlc ffmedia player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google tqalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscadfgn Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("googldfge talk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /Q"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("Videolan sdfvlc media player 0.8.4a")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Google txalk")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("Zipscanx Evaluation")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("google talrk")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /SILENT"
				'WScript.Echo strUninstallString
 			ElseIf _
 	        	InStr(LCase(strDisplayName), LCase("11111111111")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("22222222222222")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("3333333333333333")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("4444444444444")) > 0 _
                     Then
				strUninstallString = strUninstallString & " /UNINSTALL"
				'WScript.Echo strUninstallString
			ElseIf _
				InStr(LCase(strDisplayName), LCase("vlc")) > 0 _
					Then
				strUninstallString = strUninstallString & " /S /NCRC"
				'WScript.Echo strUninstallString
			Else
				boolUnknown = True
				'WScript.Echo strUninstallString
			End If 
 
			If boolUnknown = True Then
			      On Error Resume Next
			      Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
			      If Err.Number = 0 Then
			            On Error GoTo 0
			            objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Silent uninstall unknown for " & strDisplayName & " with Uninstall string of " & strUninstallString
			            objFile.Close
			      Else
			            Err.Clear
			            On Error GoTo 0
			      End If
			Else
			      On Error Resume Next
			      intReturn = objShell.Run(strUninstallString, 1, True)
			      If Err.Number = 0 Then
			      	  Err.Clear
			      	  On Error GoTo 0
				      If intReturn = 0 Then
				            On Error Resume Next
				            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				            If Err.Number = 0 Then
				                  On Error GoTo 0
				                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Uninstalled " & strDisplayName
				                  objFile.Close
				            Else
				                  Err.Clear
				                  On Error GoTo 0
				            End If
				      Else
				            On Error Resume Next
				            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
				            If Err.Number = 0 Then
				                  On Error GoTo 0
				                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Failed to uninstall " & strDisplayName & " with Uninstall string of " & strUninstallString
				                  objFile.Close
				            Else
				                  Err.Clear
				                  On Error GoTo 0
				            End If
				      End If
				 Else
				 	Err.Clear
		            On Error Resume Next
		            Set objFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
		            If Err.Number = 0 Then
		                  On Error GoTo 0
		                  objFile.WriteLine Now & ": " & objNetwork.ComputerName & " - Could not execute Uninstall string of " & strUninstallString & " for  " & strDisplayName
		                  objFile.Close
		            Else
		                  Err.Clear
		                  On Error GoTo 0
		            End If
				 End If
			End If
 
			DataList.MoveNext
		Wend
	Else
		'WScript.Echo "No software found for " & strSoftware
	End If
Next

Open in new window

Author

Commented:
Rob for the /uninstall and  /S /NCRC if i need to add more names what do i need to do

strUninstallString = strUninstallString & " /UNINSTALL"
                        'WScript.Echo strUninstallString
                  ElseIf _
                        InStr(LCase(strDisplayName), LCase("WinRAR archiver")) > 0 or _


                              Then
                        strUninstallString = strUninstallString & " /S /NCRC"
                        'WScript.Echo strUninstallString
                  Else
                        boolUnknown = True
                        'WScript.Echo strUninstallString
                  End If
Most Valuable Expert 2012
Top Expert 2014

Commented:
For the /UNINSTALL switch you will see I added 11111111111 and 222222222222 and 3333333333333 and 44444444444444 which will never exist, so they are just placeholders, which you can change to actual names as you find them.

Above this
                        strUninstallString = strUninstallString & " /S /NCRC"

you can just use the same thing, but keep the vlc player there as one of the names.

This is what that section would look like



                   ElseIf _
                     InStr(LCase(strDisplayName), LCase("11111111111")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("22222222222222")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("3333333333333333")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("4444444444444")) > 0 _
                     Then
                        strUninstallString = strUninstallString & " /UNINSTALL"
                        'WScript.Echo strUninstallString
                   ElseIf _
                     InStr(LCase(strDisplayName), LCase("vlc")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("22222222222222")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("3333333333333333")) > 0 Or _
                     InStr(LCase(strDisplayName), LCase("4444444444444")) > 0 _
                     Then
                        strUninstallString = strUninstallString & " /S /NCRC"
                        'WScript.Echo strUninstallString

Author

Commented:
Sorry Rob i know you would have been annoyed by my questions...But please bare with me..

I get this in the log

11/13/2009 11:54:17 AM: INRV03 - Could not execute Uninstall string of C:\Program Files\Google\Google Desktop Search\GoogleDesktopSetup.exe -uninstall /UNINSTALL for  google desktop
11/13/2009 11:54:17 AM: INRV03 - Could not execute Uninstall string of C:\Program Files\WinRAR\uninstall.exe /UNINSTALL for  winrar archiver
11/13/2009 11:57:45 AM: INSRV03 - Could not execute Uninstall string of C:\Program Files\Ahead\nero\uninstall\UNNERO.exe /UNINSTALL /UNINSTALL for  nero 6 demo

if it cannot uninstall. Any way it can mention with what switch it can. So i can try that
Most Valuable Expert 2012
Top Expert 2014

Commented:
No, there is no way to automatically find out what switch can silently uninstall some products. Some products do not offer a silent install at all, so it is impossible to use any switch to silently uninstall them, they must be done manually.

Rob.

Author

Commented:
Thanks a lot for this Rob... :-)
Any help on the other posts..Do you have time today...
Most Valuable Expert 2012
Top Expert 2014

Commented:
Unfortunately I'm not going to have much time available for a while, as we are trying to finish our Lotus Notes R8 roll out, and also start our Office 2007 deployment, so I need to work pretty heavily on those....along my everyday support job!  I'm going to be busy!

Rob.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial