Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uninstalling software using script

Status
Not open for further replies.

Namitas

Programmer
Jun 11, 2008
5
US
I have to write a Vb script for uninstalling the software from the systems on network.
I have already written scripts for uninstallation using msiexec.exe and it worked but when I tried it for unistalling one of the google software, it doesnt work, n then i checked the installation script for that software, I find that a different method is used to install it rather than the normal using .msi and .mst formats.

I am also adding the installation lines:
strAppInstallPath = strAppsShareRoot & "\Google\Sketchup.Pro.6\install.bat " & strAppsShareRoot & "\Google\Sketchup.Pro.6\googlesketchupprowen.exe /a /s /sms /f1" & strAppsShareRoot & "\Google\Sketchup.Pro.6\setup.iss /f2c:\setup.log"
' ***** Install Sketchup 6 if it's not already installed
If (IsProductInstalled("{12E75B98-8463-4C1F-8DDA-F6CF31566A55}") = False) Then
WshShell.Run strAppInstallPath,2,True
objfso.CopyFile strAppsShareRoot & "\google\sketchup.pro.6\server.dat", "c:\program files\google\Google SketchUp 6\", True
objfso.CopyFile strAppsShareRoot & "\google\sketchup.pro.6\Ruby_Script\SimplifyContours.rb", "C:\Program Files\Google\Google SketchUp 6\Plugins", True
End If


so can any body suggest me that how can I uninstall thi s software using scripts
I have tried:
If (IsProductInstalled("{12E75B98-8463-4C1F-8DDA-F6CF31566A55}") = True) Then
WshShell.Run "msiexec.exe /uninstall {12E75B98-8463-4C1F-8DDA-F6CF31566A55} /quiet",,True

End If
' ***** Update log for this workstation (check to see if it uninstalled successfully)
If (IsProductInstalled(strProductID) = False) Then
WshShell.LogEvent EVENT_SUCCESS, "Uninstalled " + strProductName
Else
' ***** Exit the script if product couldn't be removed
WshShell.LogEvent EVENT_ERROR, "Unable to remove " + strProductName
Wscript.Quit 0
End If

but its not working
It runs bt doesnt uninstall........


Need help!!!!!!!!!!!!!!!!!!!

 
What software is it that piece of google...? Is it malware? Could you declare where is it from? Don't seem to be from google.
 
Its a google product Sketchup 6 used by Architects.
Actaully I work in Construction company in their IT deptt.
 
Okay, thanks! When I google (yes that agan) that exe, it only returns some suspects sites!
 
Here is an example of what I've done to remove Winzip :

Code:
'*******************************************************************
Function RemoveWinZip(strPCName)
WScript.Echo "Funtion RemoveWinZip has been called for " & strPCName
LogFile.WriteLine strPCName & ",beginning Remove Process"

'  Based on code found at MS Scripting Site:
'  [URL unfurl="true"]http://www.microsoft.com/technet/scriptcenter/scripts/os/process/procthd/pcthvb03.mspx?mfr=True[/URL]
'  and 
'  [URL unfurl="true"]http://www.computerperformance.co.uk/vbscript/wmi_process_start.htm[/URL]

'  WMI Win32_Process info
'  [URL unfurl="true"]http://msdn2.microsoft.com/en-us/library/aa389388.aspx[/URL]


	NValueName = "DisplayName"
	VValueName = "DisplayVersion"
	UValueName = "UninstallString"
	On Error Resume Next
'  Remove Shell Extension
	Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\default:StdRegProv")
	LogFile.Writeline strPCName & "," & err & "," & err.description
	Wscript.Echo strPCName & " " & err & " " & err.description
	strKeyPath = "Software\Nico Mak Computing\WinZip\fm"
	ValueName = "shlExt"
	objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, 0
'  End Remove Shell Extension
' *** Read the uninstall registry to find the program you want to uninstall ***
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 'The path in the Registry needed to search
	Set oReg = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & strPCName & "\root\default:StdRegProv")
	
	oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
	For Each subkey In arrSubKeys
	searchkey = strKeyPath & "\" & subkey
	  oReg.GetStringValue HKEY_LOCAL_MACHINE, searchkey, NValueName, strDisplayName
      oReg.GetStringValue HKEY_LOCAL_MACHINE, searchkey, VValueName, strDisplayVersion
      oReg.GetExpandedStringValue HKEY_LOCAL_MACHINE, searchkey, UValueName, strUninstall
' *** Test for the program from ***      
     intTest=InStr(strDisplayName,"WinZip")
       	If intTest <> 0 and intTest <> "" Then
' *** Test to see if the uninstall is an msi, cause these are easy ***
		intUnin=Instr(strUninstall,"MsiExec")
    		If intUnin <> 0 and intUnin <> "" Then
    		Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
			Set objProcess = objWMIService.Get("Win32_Process")
			Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
			' objProgram.CommandLine = strUninstall & " /qn" : only if the uninstall string already has /x
			objProgram.CommandLine = Replace(strUninstall,"/I","/X") & " /qn"
			LogFile.Writeline "Uninstalled " & strDisplayName & "," & strDisplayVersion & " using " & objProgram.CommandLine
			Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
			'Sleep script
			Set objShell = CreateObject("Wscript.Shell")  
  			strCommand = "%COMSPEC% /c ping -n " & intSeconds & " 127.0.0.1>nul"  
  			objShell.Run strCommand, 0, True  
  			Set objShell = Nothing
			'End Sleep script
			Else
' *** Okay, so its not going to be easy.  Get the uninstall string from the registry ***
				Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
				Set objProcess = objWMIService.Get("Win32_Process")
				Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
		' Here is where it gets tricky.  You have to get some samples of the uninstall and 
		' see what makes it run silently.  Then tack on "x" or insert "/s" where needed using 
		' objProgram.CommandLine = Replace(strUninstall,"/I","/X") & " /qn" : or similar methods.
				objProgram.CommandLine = strUninstall & "x"
				LogFile.Writeline "Uninstalled " & strDisplayName & "," & strDisplayVersion & " using " & objProgram.CommandLine
				Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
			'Sleep script
			Set objShell = CreateObject("Wscript.Shell")  
  			strCommand = "%COMSPEC% /c ping -n " & intSeconds & " 127.0.0.1>nul"  
  			objShell.Run strCommand, 0, True  
  			Set objShell = Nothing
			'End Sleep script
			End If
End If
Next

' Now, if both the above failed to remove the dang program, do it the hard way....

			Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("\\" & strPCName & "\C$\Program Files\WinZip\WINZIP32.EXE") Then
    Set objWMIService=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
				Set objProcess = objWMIService.Get("Win32_Process")
				Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
				objProgram.CommandLine = "C:\Program Files\WinZip\WINZIP32.EXE /uninstallx"
				LogFile.Writeline ",No registry entry, trying uninstall " & strDisplayName & "," & strDisplayVersion & " using " & objProgram.CommandLine
				Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
Else
    Wscript.Echo "WinZip does not exist on C:\."
    LogFile.Writeline strPCName & ",WinZip does not exist on C:\"
End If
			
Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists("\\" & strPCName & "\E$\Program Files\WinZip\WINZIP32.EXE") Then
				Set objProcess = objWMIService.Get("Win32_Process")
				Set objProgram = objProcess.Methods_("Create").InParameters.SpawnInstance_
				objProgram.CommandLine = "E:\Program Files\WinZip\WINZIP32.EXE /uninstallx"
				LogFile.Writeline ",No registry entry, trying uninstall " & strDisplayName & "," & strDisplayVersion & " using " & objProgram.CommandLine
				Set strShell = objWMIService.ExecMethod("Win32_Process","Create",objProgram)
	Else
    Wscript.Echo "WinZip does not exist on E:\."
    LogFile.Writeline strPCName & ",WinZip does not exist on E:\"
End If
 '	<< I cut out a lot of junk here involving deleting winzip folders, so might have removed or kept a wrong line or two >> 
Next
Set objWMIService = Nothing
Set colFolders = Nothing
Set colFolders2 = Nothing
End Function  'RemoveWinZip(strPCName)
 
... you know, maybe I should have asked before, but if you go to the add/remove programs and uninstall it, does it work there? Also, try using the uninstall string from the registry in the command window - does it uninstall correctly then?
 
ya when I try to unistall from ADD/REmove , it get unistalled manually
 
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\default:StdRegProv")

I have a question , do I need to change it to
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\cimv2")
 
''Remove Shell Extension
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strPCName & "\root\default:StdRegProv")
LogFile.Writeline strPCName & "," & err & "," & err.description
Wscript.Echo strPCName & " " & err & " " & err.description
strKeyPath = "Software\Nico Mak Computing\WinZip\fm"
ValueName = "shlExt"
objReg.SetStringValue HKEY_CURRENT_USER, strKeyPath, ValueName, 0
' End Remove Shell Extension


I am not able to understand this part
what eaxctly the strKeypath is ?
n also ValueName=?

What changes I should make in my scripts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top