VBScript to automatically & silently remove ZenWorks regardless of version, with no hard manual labor

Novell ZenWorks Configuration ManagementVBScript to automatically remove ZenWorks regardless of version, with no user prompting or hard manual labor

Adding to my collection of VBScript tools for migrating from Novell to Microsoft, here is a little gem to removing ZenWorks, by reading the uninstall information on the computer, we find any version of ZenWorks and the command to uninstall it quietly and without any user prompts.

In a few situations the computer will fail to uninstall ZenWorks, the primary reason for me has been on a computer that is awaiting a reboot from a previous install or uninstall procedure. Simply rebooting the machine and running the script again seems to fix this problem. I have made a script to do that as well, but I dont want to overcomplicate things, and will just post the snippet of how to actually uninstall it here.

You should test this before using it in production, and always at own risk, dont forget to add error handling and logging as needed. Enjoy!

‘ You may use this script and parts of it as you please, all that I ask is that you give a small thank you note on my blog <a href="http://www.sole.dk">www.sole.dk</a>
‘ Enjoy and use at own risk!

On Error Resume Next ' We dont like users finding out we cant program!

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

' I would like to know what version of ZenWorks this is, only to find out if i uninstalled it successfully.
' You may remove this if you dont care

SubKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
ValueName = "DisplayVersion"
KeyType = REG_SZ
' This is all the GUID's I have found so far that is related to ZenWorks
' if you find a version, that is not in here, go to the location in registry you see in SubKey
' Go thru each GUID and find the one with ZenWorks, and add it below
' Also do write a comment with the GUID and version you found on <a href="http://www.sole.dk">www.sole.dk</a> !
GUIDArray = Array(_
"{7878B1D4-B2CB-4EA8-9A0A-7E0575D23B96}",_
"{98D19358-EB82-4E14-B26B-D3481C7AA0A5}",_
"{309C3793-54FA-4145-AA14-27ACBE8D926E}",_
"{E25DEBB3-C403-4DAC-A98B-94E4C47E0FBE}",_
"{F5DB4286-0064-4574-936B-09115C7A5A07}"_
)
' We search each guid to see if it exist and what displayversion it is
For Each GUID In GUIDArray
    objReg.GetStringValue HKLM, SubKey & GUID, ValueName, Value
    If Len(Value) > 2 Then
        WScript.Echo "ZenWorks GUID Found : " & GUID & " DisplayVersion = " & Value
        WshShell.Run "Taskkill.exe /f /im zenrem32.exe", 0, False ' Kill the ZenWorks mgt agent in case it hangs, so it wont block our uninstall, and we dont want to wait before continueing, so False.
        WshShell.Run "MsiExec.exe /x " & GUID & " REBOOT=ReallySuppress /qn", 0, True ' I dont want the uninstall to reboot or show anything to the user...
        WScript.Echo "Checking if uninstalled."
        objReg.GetStringValue Key, SubKey & GUID, ValueName, Value2
        If Value = Value2 Then
            WScript.Echo "UN-Successfull uninstall of ZenWorks Version: " & Value
        Else
            WScript.Echo "Successfull uninstall of ZenWorks Version: " & Value
        End If  
    End If  
Next
'Cleanup
Set objReg = Nothing
Set WshShell = Nothing

Related posts:

  1. How to silently install ZenWorks 10 with vbScript without having to watch the screen during installation So You want to install ZenWorks 10.x.x.x silently on a machine, sounds easy enough right? Well ZenWorks is...
  2. VBScript to automatically remove a Novell client and save your feet Adding to my remote Novell migration and removal toolkit, is here below a VBScript that can be used...
  3. VBScript to remove network printers, when RemovePrinterConnection fails and still have time for popcorn and a movie For the last couple of months, and some months ahead, I am working primarely on migration projects, currently...
  4. VBScript to join computers to domain, with specific user and avoid having to manually place them in AD The following script was used for automatically joining alot of computers to an Active Directory domain, it was...

10 Responses to “VBScript to automatically & silently remove ZenWorks regardless of version, with no hard manual labor”

  • Sole:

    Today I debugged an error when using this script to uninstall ZenWorks, on a very few installations, it would hang and never continue, so the script would never complete, and never ask the machine to reboot. The clients would never get ZenWorks uninstalled. When trying to manually uninstall ZenWorks I found the cause, and have now implemented a small 1 line fix to solve this problem.

    The problem causing the “hang” during uninstall is described on Novell here http://support.novell.com/docs/Tids/Solutions/10095223.html Basicly it says that the ZENworks mangement agent on a very specific version gets stuck on “Starting…” and therefore the uninstall cant stop the service and continue. I opted for the fix of just killing the task, since i dont realy care if it stops cleanly, after all I am removing it !

    I have added the extra lines in the original post.

  • saulnier:

    bonjour je suis actuellement en stage et mon tuteur ma demander de faire un script ou un .exe car nous quittons netware pour de l’open source et votre script conviendrait a sa demande mais cependant je ne c pas quoi reprendre car kan je reprend presque tout une foi que je le lance il me met un message d’erreur merci de me guider

  • saulnier:

    Hello I am currently in my internship and my tutor asked to make a script or. exe netware because we leave for the open source and your script should have its application, but yet I do not c anything back because when I follow almost all a faith that I run it it makes me an error message to guide me thank you

  • Sole:

    Hi Johann,
    I am having a little trouble understanding. I assume you are asking the following, please correct me if I am wrong. You are looking for a script or executeable that will remove ZenWorks?
    But You do not get any feedback when running the script?

    You can run the script, by saving the text in notepad, with a filename.vbs
    then run it with for example this command: cscript.exe filename.vbs

    If you did it correctly, it should output Successfull or Unsuccessfull uninstall of ZenWorks if it finds a ZenWorks installation in registry. Note I do NOT have all the GUID’s associated with ZenWorks, only the ones I have seen in my work.

    You can add this line in the end of the script to check that it runs correctly.

    wscript.echo “Script completed.”

    If you do have zenworks installed, but it doesnt uninstall it, open regedit and go into this key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\

    Now go thru each GUID {some-long-number} and find the one with a ZenWorks name inside it.
    Add the GUID you find and add it like the others in the script. It should now be able to remove your version.

    Enjoy!

  • Sole:

    Found another GUID for ZenWorks {17ABBB0D-F2B1-4C78-A64F-2DC1C1E7A4DE}

  • Found a GUID for ZenWorks that we have {20F7117E-1B6F-4EEC-8F47-FB7A142FAC12}

  • 02J:

    Excellent script. I added a small modification to write results to a SQL DB.

    Here are some additional Agent GUIDs with Version:

    “{C5E122A0-09A8-4B9D-A010-9B20F5348C09}”_ ‘ 6.5.14.40614
    “{F5DB4286-0064-4574-936B-09115C7A5A07}”,_ ‘ 6.5.84.50204
    “{0028ED8D-E938-4B81-B636-F20B3207086F}”,_ ‘ 7.0.101.70213
    “{17ABBB0D-F2B1-4C78-A64F-2DC1C1E7A4DE}”,_ ‘ 7.0.7.50808

    Here’s what relevant portion the original code + my SQL code looks like: (I’m not sure why I needed the portion “Version = Value”. When I tried to use Value directly it wouldn’t work. The sections enclosed in will need to be replaced with appropriate settings for your environment.)

    ‘ We search each guid to see if it exist and what displayversion it is
    For Each GUID In GUIDArray
    objReg.GetStringValue HKLM, SubKey & GUID, ValueName, Value
    If Len(Value) > 2 Then
    WScript.Echo “ZenWorks GUID Found : ” & GUID & ” DisplayVersion = ” & Value
    WshShell.Run “Taskkill.exe /f /im zenrem32.exe”, 0, False ‘ Kill the ZenWorks mgt agent in case it hangs, so it wont block our uninstall, and we dont want to wait before continueing, so False.
    WshShell.Run “MsiExec.exe /x ” & GUID & ” REBOOT=ReallySuppress /qn”, 0, True ‘ I dont want the uninstall to reboot or show anything to the user…
    WScript.Echo “Checking if uninstalled.”
    objReg.GetStringValue Key, SubKey & GUID, ValueName, Value2
    If Value = Value2 Then
    WScript.Echo “UN-Successfull uninstall of ZenWorks Version: ” & Value
    sAction = “Failure”
    Version = Value
    Else
    WScript.Echo “Successfull uninstall of ZenWorks Version: ” & Value
    sAction = “Success”
    Version = Value
    End If
    End If
    Next

    Set objNetwork = CreateObject(“Wscript.Network”)
    strComputerName = objNetwork.ComputerName
    Set mConnection = CreateObject(“ADODB.Connection”)
    mConnection.Open “Provider=SQLOLEDB.1;Data Source=;Initial Catalog=”,”",”"
    Set rs = mConnection.Execute(“SELECT NEWID()”)
    If Not rs.EOF Then GUID = rs(0)
    mConnection.Execute “DECLARE @GUID uniqueidentifier; SET @GUID = ‘” & GUID &”‘; INSERT INTO (ID, Computer, Action, Version, Time) VALUES (@GUID, ‘” & strComputerName & “‘, ‘” & sAction & “‘, ‘” & Version & “‘, ‘” & Now() & “‘)”
    Set mConnection = Nothing

  • 02J:

    (Portions of the last post were stripped, replaced the with [].

    Excellent script. I added a small modification to write results to a SQL DB.
    Here are some additional Agent GUIDs with Version:
    “{C5E122A0-09A8-4B9D-A010-9B20F5348C09}”_ ‘ 6.5.14.40614
    “{F5DB4286-0064-4574-936B-09115C7A5A07}”,_ ‘ 6.5.84.50204
    “{0028ED8D-E938-4B81-B636-F20B3207086F}”,_ ‘ 7.0.101.70213
    “{17ABBB0D-F2B1-4C78-A64F-2DC1C1E7A4DE}”,_ ‘ 7.0.7.50808
    Here’s what relevant portion the original code + my SQL code looks like: (I’m not sure why I needed the portion “Version = Value”. When I tried to use Value directly it wouldn’t work. The sections enclosed in [], will need to be replaced with appropriate settings for your environment.)

    ‘ We search each guid to see if it exist and what displayversion it is
    For Each GUID In GUIDArray
    objReg.GetStringValue HKLM, SubKey & GUID, ValueName, Value
    If Len(Value) > 2 Then
    WScript.Echo “ZenWorks GUID Found : ” & GUID & ” DisplayVersion = ” & Value
    WshShell.Run “Taskkill.exe /f /im zenrem32.exe”, 0, False ‘ Kill the ZenWorks mgt agent in case it hangs, so it wont block our uninstall, and we dont want to wait before continueing, so False.
    WshShell.Run “MsiExec.exe /x ” & GUID & ” REBOOT=ReallySuppress /qn”, 0, True ‘ I dont want the uninstall to reboot or show anything to the user…
    WScript.Echo “Checking if uninstalled.”
    objReg.GetStringValue Key, SubKey & GUID, ValueName, Value2
    If Value = Value2 Then
    WScript.Echo “UN-Successfull uninstall of ZenWorks Version: ” & Value
    sAction = “Failure”
    Version = Value
    Else
    WScript.Echo “Successfull uninstall of ZenWorks Version: ” & Value
    sAction = “Success”
    Version = Value
    End If
    End If
    Next

    Set objNetwork = CreateObject(“Wscript.Network”)
    strComputerName = objNetwork.ComputerName
    Set mConnection = CreateObject(“ADODB.Connection”)
    mConnection.Open “Provider=SQLOLEDB.1;Data Source=;Initial Catalog=[database name]“,”[databse username]“,”[database password]”
    Set rs = mConnection.Execute(“SELECT NEWID()”)
    If Not rs.EOF Then GUID = rs(0)
    mConnection.Execute “DECLARE @GUID uniqueidentifier; SET @GUID = ‘” & GUID &”‘; INSERT INTO RemovalActions (ID, AD_Computer, Action, Version, Time) VALUES (@GUID, ‘” & strComputerName & “‘, ‘” & sAction & “‘, ‘” & Version & “‘, ‘” & Now() & “‘)”
    Set mConnection = Nothing

  • Sole, will this script run for users with limited policy rights? Or, if possible, can the script run in what’s know as workstation security space?
    Thanks!

  • Sole:

    Hi Jeff,
    I would guess that the script would be unsuccessfull if used for users with limited rights, i.e. if they are not able to remove an application in add/remove programs, then this script should not work. Otherwise it should be fine.
    As far as I can tell I am not using any user specific tools/registry or other modules, so it should be fine to run it under computer context, i.e. in a computer startup script in a GPO.

    If You use it for either, please let me know if it works :)

Leave a Reply