Wednesday, December 11, 2013

Remove Novell Client

This script will remove Novell Clients for workstations. It was meant to be deployed via SCCM
 'RemoveNovell.vbs - Checks for OS  
 'Removes Novell client depending on OS version (XPx86, 7x64)  
 On Error Resume Next  
 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  
 '==========================================================================  
 Function Os64Bit()   
   Os64Bit = False   
   Dim colOS : Set colOS = GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 48)   
   Dim objOS   
   For Each objOS In colOS   
     If objOS.AddressWidth = 64 Then Os64Bit = True   
   Next   
 End Function  
 '==========================================================================  
 Sub Novellon7x64  
 'WScript.Echo "Sub Novellon7x64"  
 Set WSHShell = WScript.CreateObject("WScript.Shell")  
 Set WSHExec = CreateObject("Shell.Application")  
 ' used For executing a command line command   
 ' %SystemRoot%\System32\rundll32 "C:\Program Files\Novell\Client\ncsetup.dll" NWUninstallClient  
 strProgFilesx86 = WSHShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")  
 strProgFiles = WSHShell.ExpandEnvironmentStrings("%ProgramFiles%")  
 'Determine Novell Version for Error Handling   
 strRoot = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Novell Client for Windows\"  
 strName = "DisplayName"  
 strValue = WSHShell.RegRead(strRoot & strName)  
 If IsNull(strValue) Then  
   'WScript.Echo "Novell is not installed"  
   Logit "RemoveNovellcleanup"  
 Else  
      strSetupCS = WSHShell.ExpandEnvironmentStrings("%COMSPEC%") ' & " /c | " & WSHShell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\rundll32.exe " & WSHShell.ExpandEnvironmentStrings("%ProgramFiles%") & """\Novell\Client\ncsetup.dll"" /s"  
      strSetupNC = "/c " & WSHShell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\rundll32.exe """ & WSHShell.ExpandEnvironmentStrings("%ProgramFiles%") & "\Novell\Client\ncsetup.dll"" NWUninstallClient /s"  
      strNICI = WSHShell.ExpandEnvironmentStrings("%WINDIR%") & "\system32\MsiExec.exe /X{559D2B32-5066-4762-A2F2-52831AC6F67B} /qn"  
   Msgbox "Removing Novell Client, UnInstaller will automatically REBOOT your PC when it is done. PLEASE Ensure all your data files are saved and closed before clicking OK!",48,"Novell Client Removal"  
      jnk = WsHExec.ShellExecute (strSetupCS,strSetupNC,"","runas",1) ' runas, Elevated  
      '*** PC will likely now Reboot and remaining checks will not be run ***  
      '*** Future launches of script will find no Novell client during initial check ***  
   'Verify Novell Version has been removed and Log results   
   strValue2 = WshShell.RegRead(strRoot & strName)  
      If IsNull(strValue2) Then  
           'WScript.Echo "Novell is not installed"  
           Logit "RemoveNovellcleanup"  
   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\Novell"  
 ValueName = "CurrentVersion"  
 KeyType = REG_SZ   
 objReg.GetStringValue Key, SubKey, ValueName, Value   
 'WScript.Echo "Novell found - version = " & Value   
 If IsNull(Value) Then  
   'WScript.Echo "Novell is not installed"  
      Logit "RemoveNovellcleanup"  
 Else   
   'WScript.Echo "Removing Novell Client, please wait."  
   Msgbox "Removing Novell Client, UnInstaller will automatically REBOOT your PC when it is done. PLEASE Ensure all your data files are saved and closed before clicking OK!",48,"Novell Client Removal"  
      WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u ms_nwspx", 0, True ' 0 minimized, True wait for completion   
   WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u ms_nwnb", 0, True  
   WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u ms_nwipx", 0, True  
   WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u nw_wm", 0, True  
   WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u nw_ndps", 0, True  
   WshShell.Run "%WINDIR%\system32\NetWare\Nwmigw2k\setupw2k.exe /u nw_nwfs", 0, True  
   'WScript.Echo "Novell Client removal process has completed, please restart Windows to ensure all uneeded systems are stopped."     
   'Verify Novell Version has been removed and Log results   
   objReg.GetStringValue Key, SubKey, ValueName, Value2   
   If Value = Value2 Then  
     Logit "RemoveNovellcleanup"  
   Else  
     Logit "RemoveNovellcleanup"  
   End If  
 End If  
 'restart, wait 5 seconds, force running apps to close  
 WshShell.Run "%comspec% /c shutdown /r /t 5 /f", , TRUE  
 'Cleanup  
 Set objReg = Nothing  
 Set WshShell = Nothing  
 WScript.Quit  
 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  
 '==========================================================================  

2 comments:

  1. I'm gonna give this a whirl on my next Novell to AD migration. Thanks!

    ReplyDelete
  2. If this is supposed to be delivered with SCCM, how do you suppress the "Are you sure you want to remove Novell Client for Windows" prompt and the prompt to reboot? Currently, the script is not 100%, so it's getting hung on any systems I deploy it to.

    I know there's a program called "AutoIt" that can interact with prompts, it's just not the easiest to finagle. Anyone else able to completely suppress these prompts so it can be automated?

    ReplyDelete