ZCM Client Updater

over 8 years ago

A utility (CMD script) combined with the WGET utility, to download and install the latest available ZCM Client from your primary ZENworks server.

I am using this to manually upgrade ZCM 10.x / 11.x to 11.2.3a.

The script downloads files to the workstation into the directory "%TEMP%\ZENRRWEB\".

When launched, the script prompts the User with a menu to select what to download and install.

After a selection is made, the script downloads the selected stand-alone installer from the primary

Selection Download
Full ZCM Client PreAgentPkg_AgentComplete.exe
Inventory Only Module (IOM) ZENworks_Adaptive_Agent_Windows.exe

The script detects the architecture of the OS and obtains the correct installer. (Windows 32 or 64 Bit only).

Once the download has been verified, the existing client is removed, Full Client or the IOM.

After the removal has finished, the installer then begins.

If installing the Full Client, the script will terminate BEFORE the client installer's process completes.

In this case, the script notifies the user that the installer will prompt when it has completed.

Pressing a key at this point will cause the CMD Window to close.

This is what should be displayed once the Full Client installer is complete.

After rebooting, you will need to manually register the computer to the correct registration key. Since this script is for general use, the machines will register using the default key.

If installing the IOM, the script terminates AFTER the installer is completed.

Note the "Done! Reboot and Test . . ." notification.

If you want it to register automatically to a specific key, search for the line in the script that launches the Full Client installer:

start "" /b /wait "%TEMP%\PreAgentPkg_AgentComplete.exe" "-x"

and modify it to look like this, using your preferred key:

start "" /b /wait "%TEMP%\PreAgentPkg_AgentComplete.exe" "-x -k XXX"

A couple of things you must do if you use this script:

Modify the environment variables defined at the top of the script to contain valid values

Update these:


Download WGET and put it in the same directory that you will place the script. The one I am using, I got from here: https://osspack32.googlecode.com/files/wget-1.14.exe.

There is nothing to configure related to the IOM installer.

Copy and paste the contents of this box to a .cmd or .bat file and perform the above mentioned customization.

@echo off
REM Ed Radke
REM Developed under ZCM 10/11
REM If vars are not already defined, define them here.
REM I got it here: https://osspack32.googlecode.com/files/wget-1.14.exe
REM currently defined as being in the same directory as the script.
set __WGET=%~dp0wget-1.14.exe
echo This script downloads and installs the latest available ZCM Client.
echo If a ZCM Client is already installed,
echo a normal un-installation occurs prior to this install.
echo Select:
echo 1 Install Full ZCM Client
echo 2 Install Inventory only module (IOM)
set /p __SELECT=^>^>^>:
if "%__SELECT%"=="1" call :FULL
if "%__SELECT%"=="2" call :IOM
if not defined __SUCCESS (
echo ABORT!
echo An invalid selection was made or,
echo the download has failed. Nothing has been changed.
goto :EOF
echo Download was successful, Un-installing ZCM if it exists.
REM Uninstall Zenworks
"%ZENWORKS_HOME%\bin\zac.exe" unr -u %__USER% -p %__PASS% > NUL 2>&1
"%ZENWORKS_HOME%\bin\ZENworksUninstall.exe" --local-only --remove-auth --quiet > NUL 2>&1
REM Attempt to remove any remaining components, this will also remove the IOM
call :MSI_REMOVE zenworks >NUL 2>&1
call :MSI_REMOVE casa >NUL 2>&1
rmdir /s /q "%__ZENHOME%" >NUL 2>&1
rmdir /s /q "%__ZENHOME%\..\CASA" >NUL 2>&1

REM Install Zenworks
echo Installing Selection . . .
if "%__SELECT%"=="1" (
start "" /b /wait "%TEMP%\PreAgentPkg_AgentComplete.exe" "-x"
echo The installer will prompt when it has completed . . .
if "%__SELECT%"=="2" (
start "" /b /wait "%TEMP%\ZENworks_Adaptive_Agent_Windows.exe" "-S"
echo Done! Reboot and Test . . .
goto :EOF

REM wmic product where (name like "%Zenworks%") get name,packagecache /format:csv
REM A string that will be searched for in the product name to be uninstalled, BE CAUTIOUS WHAT YOU TYPE HERE
if "%1"=="" goto :EOF
set __FILTER=%*
REM Output of wmic
REM Remove output if it exists
if exist "%__OUT%" del /f /q "%__OUT%" >NUL 2>&1
echo Initializing
REM search for MSI product's local package
wmic /output:"%__OUT%" product where (name like "%%%__FILTER%%%") get name,packagecache /format:csv
REM Convert output to ANSI
type "%__OUT%" >"%__OUT%.tmp"
type "%__OUT%.tmp" >"%__OUT%"
for /f "usebackq tokens=2,3 skip=2 delims=," %%A in ("%__OUT%") do (
echo Un-installing "%%A"
msiexec.exe /qn /x "%%B"
goto :EOF
if exist "%TEMP%\ZENworks_Adaptive_Agent_Windows.exe" del /f "%TEMP%\ZENworks_Adaptive_Agent_Windows.exe">NUL 2>&1
"%__WGET%" -P "%TEMP%" --no-check-certificate %__DLHOST%/zenworks-downloads/inventory/Windows/ZENworks_Adaptive_Agent_Windows.exe
if exist "%TEMP%\ZENworks_Adaptive_Agent_Windows.exe" set __SUCCESS=1
goto :EOF

if exist "%TEMP%\PreAgentPkg_AgentComplete.exe" del /f "%TEMP%\PreAgentPkg_AgentComplete.exe">NUL 2>&1
"%__WGET%" -P "%TEMP%" --no-check-certificate %__DLHOST%/zenworks-downloads/setup/x86/PreAgentPkg_AgentComplete.exe
"%__WGET%" -P "%TEMP%" --no-check-certificate %__DLHOST%/zenworks-downloads/setup/x86_64/PreAgentPkg_AgentComplete.exe
if exist "%TEMP%\PreAgentPkg_AgentComplete.exe" set __SUCCESS=1
goto :EOF

By the way, this script utilized the code I wrote for my published "(GroupWise) uninstall script" Tool



How To-Best Practice
Comment List
Related Discussions