Wednesday, December 11, 2013

Remove Novell IPrint

this script makes use of the nipp-su.exe iprint client uninstaller from Novel.
 'RemoveIPrint.vbs - Checks for OS  
 'Removes IPrint client depending on OS version (XP, 7)  
 On Error Resume Next  
 DeliPrinters 'remove iprint devices  
 If Win7 = True Then  
           'WScript.Echo "Win7x64"  
           Novellon7x64   
           Else  
           'WScript.Echo "WinXP"  
           NovellonXP  
 End If  
 '==========================================================================  
 Function Win7()   
   Win7 = False   
   Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery("SELECT Version FROM Win32_OperatingSystem",, 48)   
   Dim objOS   
   For Each objOS In colOS   
     If objOS.Version >= "6.1.7600" Then Win7 = True   
   Next   
 End Function  
 '==========================================================================  
 Sub Novellon7x64  
 'WScript.Echo "Sub Novellon7x64"  
 Set WshShell = WScript.CreateObject("WScript.Shell")  
 Set WsHExec = CreateObject("Shell.Application")  
 strProgFilesx86 = WSHShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")  
 strProgFiles = WSHShell.ExpandEnvironmentStrings("%ProgramFiles%")  
 'Determine Novell Version for Error Handling   
 strRoot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell iPrint Client\"  
 strName = "DisplayName"  
 strValue = WshShell.RegRead(strRoot & strName)  
 strSetupCS = WSHShell.ExpandEnvironmentStrings("%COMSPEC%") ' & " /c | " & scriptDir & "\System32\rundll32.exe ""C:\Program Files\Novell\Client\ncsetup.dll"" /s"  
 strSetupNC = "/c " & scriptDir & "\win-7\nipp-su.exe"  
 If IsNull(Value) Then  
   'WScript.Echo "IPrint is not installed"  
   Logit "RemoveIprint"  
 Else   
   'Msgbox "Removing IPrint Client, Please Click OK to Continue"  
      WshShell.Run scriptDir & "\win-7\nipp-su.exe", 0, True ' 0 minimized, True wait for completion   
   'Verify IPrint Version has been removed and Log results   
   strValue2 = WshShell.RegRead(strRoot & strName)  
   If strValue = strValue2 Then  
     Logit "RemoveIPrintFAILED"  
   Else  
     Logit "RemoveIPrint"  
   End If  
 End If  
 'Cleanup  
 Set WshShell = Nothing  
 WScript.Quit  
 End Sub  
 '==========================================================================  
 Sub NovellonXP  
 Const HKLM=&H80000002 'HKEY_LOCAL_MACHINE   
 Set objReg=GetObject("winmgmts:!root/default:StdRegProv")   
 ' Registry access   
 Set WshShell = WScript.CreateObject("WScript.Shell")   
 ' used For executing a command line command   
 'Determine Novell Version for Error Handling   
 Key = HKLM   
 SubKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell iPrint Client\"  
 ValueName = "DisplayName"  
 KeyType = REG_SZ   
 objReg.GetStringValue Key, SubKey, ValueName, Value   
 'WScript.Echo "IPrint found - version = " & Value   
 If IsNull(Value) Then  
   'WScript.Echo "IPrint is not installed"  
 Else   
   'Msgbox "Removing IPrint Client, Please Click OK to Continue"  
      WshShell.Run scriptDir & "\win-xp\nipp-su.exe", 0, True ' 0 minimized, True wait for completion   
   'WScript.Echo "IPrint Client removal process has completed."     
   'Verify IPrint Version has been removed and Log results   
   objReg.GetStringValue Key, SubKey, ValueName, Value2   
   If Value = Value2 Then  
     Logit "RemoveIPrintFAILED"  
   Else  
     Logit "RemoveIPrint"  
   End If  
 End If  
 'Cleanup  
 Set objReg = Nothing  
 Set WshShell = Nothing  
 WScript.Quit  
 End Sub  
 '==========================================================================  
 Sub DeliPrinters()  
 strComputer = "."  
 strOldSrv="PMAN"  
 strOldSrv5="//province_of_ns"  
 Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")  
 Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")  
 Set objNetwork = CreateObject("Wscript.Network")  
 For Each objPrinter in colInstalledPrinters  
      strPName = objPrinter.Name  
      pSwitch = InStr(objPrinter.Name, strOldSrv) or InStr(objPrinter.Name, strOldSrv5)  
      If pSwitch <> 0 Then  
           objPrinter.Delete_  
      End If       
 Next  
 'Cleanup  
 Set objNetwork = Nothing  
 Set objWMIService = Nothing  
 Set colInstalledPrinters = Nothing  
 End Sub  
 '==========================================================================  
 Sub Logit (strFlag)  
 strComputer = "."  
 Set objShell = WScript.CreateObject("WScript.Shell")  
 Set objFSO = CreateObject("Scripting.FileSystemObject")  
 strcwindows = objShell.ExpandEnvironmentStrings("%systemroot%")  
 strLogPath = strcwindows & "\CCM\Logs\"  
 Set objNetwork = CreateObject("Wscript.Network")  
 strUserName = ucase((objNetwork.UserName))  
 strcomputername = ucase((objNetwork.ComputerName))  
 Set usrLog = objFSO.OpenTextFile(strLogPath & strFlag &".log", 8, True)  
 usrLog.WriteLine (Now & ";" & strUserName & ";" & strcomputername & strFlag)  
 Set objShell = Nothing  
 Set objNetwork = Nothing  
 Set usrLog = Nothing  
 Set objFSO = Nothing  
 End Sub  
 '==========================================================================  
 'Function ScriptDir determines the Folderpath this script is in  
 Function ScriptDir  
      ScriptDir = Left(WScript.ScriptFullName,Len(WScript.ScriptFullName) - Len(WScript.ScriptName) -1)  
 End Function  
 '==========================================================================  

No comments:

Post a Comment