Uninstall

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
casamia
Posts: 6
Joined: Wed Mar 05, 2008 3:01 am

Uninstall

Post by casamia »

All,

I need to do the following: please help

1. Do not run on Servers
2. Discover machines running Microsoft proxy firewall client
3. log those clients that have client installed to central localtion (just in case on removal something goes wrong)
4. Uninstall old MS proxy firewall client (no reboot)
5. Install new proxy Firewall
6. log those clients that receive the new client ( just in case on installation something goes wrong)

Code: Select all

	
strComputer ="."
removefw
	
'****************************                         
'* removefw Subroutine **                                    
'****************************  
Sub removefw
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub is a temporary sub to remove Microsoft Firewall Client until a new image
' has been completed.
' 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oWMIService, oShell, oExplorer, colSoftware
	
' Create a shell object
Set oShell = CreateObject("WScript.Shell")
	
' Connect to the WMI provider
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
	
' Create an instance of internet Explorer and set up it's properties.
Set oExplorer = WScript.CreateObject("InternetExplorer.Application")
oExplorer.Navigate "about:blank"   
' do we want a toolbar? 1=yes 0=no
oExplorer.ToolBar = 1
' do we want a statusbar? 1=yes 0=no
oExplorer.StatusBar = 1
oExplorer.Width=400
oExplorer.Height = 200 
oExplorer.Left = 0
oExplorer.Top = 0
	
' wait for Internet Explorer to load up before updating inner html
Do While (oExplorer.Busy)
    WScript.Sleep 200
Loop    
	
' Make this instance of internet explorer visible and update
' the internal html
oExplorer.Visible = 1             
oExplorer.Document.Body.InnerHTML = "Checking for Microsoft Firewall Client 2000.  If any problems please contact HelpDesk at xxxxxx"
	
' create a query for Microsoft Firewall Client
Set colSoftware = oWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Microsoft Firewall Client'& 'DisplayVersion=3.0.1200'")
	
' check to see if there are any returns on the query
If colSoftware.count = 0 Then
 ' if not update inner html and then exit 
 oExplorer.Document.Body.InnerHTML = "No Microsoft Firewall Client Installation was found. Thank You...Exiting..."
Else
 '  if the app is found, update inner html
 For Each oSoftware in colSoftware
  oExplorer.Document.Body.InnerHTML = "Removing " & oSoftware.name
  Do While (oExplorer.Busy)
      WScript.Sleep 100
  Loop    
     oExplorer.Document.Body.InnerHTML = "Please continue to wait..."
           
     On Error Resume Next
     ' uninstall Microsoft Firewall Client
     oSoftware.Uninstall()
     
     ' error checking
     If Err.Number  0 Then
      ' if there is an error give a description of the Error
      oExplorer.Document.Body.InnerHTML = "There was an error uninstalling " & oSoftware.name
      oExplorer.Document.Body.InnerHTML = "Description: " & Err.Description
  Else
   ' if it was uninstalled successfully let the user know
   oExplorer.Document.Body.InnerHTML = oSoftware.name & " has been successfully uninstalled."
  End If
 Next
End If
	
' allow processes to finish, close IE
WScript.Sleep 3000
oExplorer.Quit  
End Sub

User avatar
casamia
Posts: 6
Joined: Wed Mar 05, 2008 3:01 am

Uninstall

Post by casamia »

All,

I need to do the following: please help

1. Do not run on Servers
2. Discover machines running Microsoft proxy firewall client
3. log those clients that have client installed to central localtion (just in case on removal something goes wrong)
4. Uninstall old MS proxy firewall client (no reboot)
5. Install new proxy Firewall
6. log those clients that receive the new client ( just in case on installation something goes wrong)

Code: Select all

	
strComputer ="."
removefw
	
'****************************                         
'* removefw Subroutine **                                    
'****************************  
Sub removefw
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' This sub is a temporary sub to remove Microsoft Firewall Client until a new image
' has been completed.
' 
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim oWMIService, oShell, oExplorer, colSoftware
	
' Create a shell object
Set oShell = CreateObject("WScript.Shell")
	
' Connect to the WMI provider
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
	
' Create an instance of internet Explorer and set up it's properties.
Set oExplorer = WScript.CreateObject("InternetExplorer.Application")
oExplorer.Navigate "about:blank"   
' do we want a toolbar? 1=yes 0=no
oExplorer.ToolBar = 1
' do we want a statusbar? 1=yes 0=no
oExplorer.StatusBar = 1
oExplorer.Width=400
oExplorer.Height = 200 
oExplorer.Left = 0
oExplorer.Top = 0
	
' wait for Internet Explorer to load up before updating inner html
Do While (oExplorer.Busy)
    WScript.Sleep 200
Loop    
	
' Make this instance of internet explorer visible and update
' the internal html
oExplorer.Visible = 1             
oExplorer.Document.Body.InnerHTML = "Checking for Microsoft Firewall Client 2000.  If any problems please contact HelpDesk at xxxxxx"
	
' create a query for Microsoft Firewall Client
Set colSoftware = oWMIService.ExecQuery _
    ("Select * from Win32_Product Where Name = 'Microsoft Firewall Client'& 'DisplayVersion=3.0.1200'")
	
' check to see if there are any returns on the query
If colSoftware.count = 0 Then
 ' if not update inner html and then exit 
 oExplorer.Document.Body.InnerHTML = "No Microsoft Firewall Client Installation was found. Thank You...Exiting..."
Else
 '  if the app is found, update inner html
 For Each oSoftware in colSoftware
  oExplorer.Document.Body.InnerHTML = "Removing " & oSoftware.name
  Do While (oExplorer.Busy)
      WScript.Sleep 100
  Loop    
     oExplorer.Document.Body.InnerHTML = "Please continue to wait..."
           
     On Error Resume Next
     ' uninstall Microsoft Firewall Client
     oSoftware.Uninstall()
     
     ' error checking
     If Err.Number  0 Then
      ' if there is an error give a description of the Error
      oExplorer.Document.Body.InnerHTML = "There was an error uninstalling " & oSoftware.name
      oExplorer.Document.Body.InnerHTML = "Description: " & Err.Description
  Else
   ' if it was uninstalled successfully let the user know
   oExplorer.Document.Body.InnerHTML = oSoftware.name & " has been successfully uninstalled."
  End If
 Next
End If
	
' allow processes to finish, close IE
WScript.Sleep 3000
oExplorer.Quit  
End Sub

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

Uninstall

Post by donj »

So, is there something specific that your script does or doesn't do, that you want to change?

I'm not sure how to "discover" machines running a particular piece of software - you'd have to connect to EVERY machine and look for a file or registry key - and it's going to take a LONG TIME depending on how many machines you have to check.

My best suggestion would be to run your script as a logon script, so that it runs locally - assuming users have permission to uninstall/install whatever you want.

User avatar
donj
Posts: 416
Joined: Thu Nov 16, 2006 9:02 pm

Uninstall

Post by donj »

You want to log to a file? No sweat. Use the FileSystemObject's OpenTextFile() method. It has a parameter that lets it append to an existing file. The method returns an object; use its WriteLine() method to add lines to the text file. Use its Close() method to close the file.

User avatar
casamia
Posts: 6
Joined: Wed Mar 05, 2008 3:01 am

Uninstall

Post by casamia »

cool.....

now what can i do to elimiate this running on servers.....

jvierra
Posts: 14552
Joined: Tue May 22, 2007 9:57 am
Contact:

Uninstall

Post by jvierra »

Also - Win32_ComputerSystem.DomainRole

Code: Select all

	
WScript.Echo GetComputerRole (WScript.Arguments(0))
	
 
	
Function GetComputerRole( strComputer )
	

    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
    Set colObj = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    For Each obj In colObj
         Select Case obj.DomainRole
              Case 0: GetComputerRole = "Standalone Workstation"
              Case 1: GetComputerRole = "Member Workstation"
              Case 2: GetComputerRole = "Standalone Server"
              Case 3: GetComputerRole = "Member Server"
              Case 4: GetComputerRole = "Backup Domain Controller"
              Case 5: GetComputerRole = "Primary Domain Controller"
         End Select
    Next
	
End Function
	

Code and driver line.

Locked