/build/static/layout/Breadcrumb_cap_w.png

Need help tweaking a script to detect and install KACE agent version 5.5.25198 through GPO.

I am trying to finish a script that will run through GPO that will detect if the KACE agent is installed and which version is installed. I have run into a snag and my script seems to be failing. Any help would be greatly appreciated. 

 

REM Setting default variables

SETLOCAL enabledelayedexpansion

SET SW32=%systemdrive%\Temp\KACE

SET LOG=%SW32%\ampagent_%computername%.log

SET COUNT=0

SET MSI=ampagent-5.5.25198-x86.msi

SET FINDER=C:\Windows\System32\find.exe

 

:VAR

 

REM Setting agent variables

SET KACE_XML_55=%ALLUSERSPROFILE%\Dell\KACE\inventory.xml

 

IF EXIST %KACE_XML_55% ((ECHO %DATE% %TIME% - Agent already installed, checking version...>>%LOG% & CALL :CHKINST)

ELSE ECHO %DATE% %TIME% - Agent not installed. Calling Installer...>>%LOG% & CALL :INSTALL

)

:CHKINST

REM Checks if and which agent(s) is installed

FOR /f "tokens=3 delims=><  " %%a IN ('TYPE C:\ProgramData\Dell\KACE\inventory.xml ^| FIND "<CLIENT_VERSION>"') DO SET AgentVersion=%%a

 

IF %AgentVersion% EQU 5.5.25198 (SET AgentOK=1 & ECHO %DATE% %TIME% - KACE Agent Version 5.5 found.>>%LOG%)

 

IF %AgentOK% EQU 0 (ECHO %DATE% %TIME% - KACE Agent needs to be updated. Calling Installer...>>%LOG% & CALL :INSTALL)

 

GOTO :EOF

 

:INSTALL

ECHO %DATE% %TIME% - Installing v5.5...>>%LOG%

IF NOT EXIST %SW32% (ECHO %DATE% %TIME% - Creating "%SW32%"...>>%LOG% & MKDIR %SW32%)

IF NOT EXIST %SW32%\%MSI% (ECHO %DATE% %TIME% - Copying "%SW32%\%MSI%"...>>%LOG% & CALL :MOUNT & COPY W:\%MSI% %SW32%\%MSI%)

start /wait msiexec.exe /qn /i %SW32%\%MSI% HOST=kace1200

ECHO %DATE% %TIME% - v5.5 Agent install complete.>>%LOG%

SET INSTALL55=1

ECHO Pausing for 1 minute & ping -n 60 127.0.0.1 >null

NET USE W: /delete

GOTO :EOF

 

:MOUNT

REM Mounts NETLOGON

ECHO %DATE% %TIME% - Mounting W:\ drive...>>%LOG%

IF EXIST W: ( ECHO %DATE% %TIME% - W:\ drive in use. Exiting...>>%LOG% & GOTO :EOF )

NET USE W: \\corp.mycompany.com\netlogon\util\KACE

IF NOT EXIST W: ( ECHO %DATE% %TIME% - W:\ drive failed to mount. Exiting.>>%LOG% & GOTO :EOF 

)

GOTO :EOF


0 Comments   [ + ] Show comments

Answers (3)

Posted by: dugullett 10 years ago
Red Belt
1

Can you not just enable automatic updates for the agent? You can also run a report for what versions your machines currently have.


Comments:
  • We have automatic updates currently enabled. The reason for the script is to re-install the agent in the case that people remove it on their own. I cant just blanket install on every machine which is why I am trying to write the logic into the script to determine if the agent is already installed and if it is the current version or not. - jparkins 10 years ago
Posted by: aragorn.2003 10 years ago
Red Belt
0

You can also use an Autoit Script or something else to read out 
the productversion of runkbot.exe

Posted by: pjgeutjens 10 years ago
Red Belt
0

Since it's an msi installer, wouldn't it be easier just to check its registry footprint?

I'm thinking HKLM\SOFTWARE\Microsoft\Windows\Currentversion\Uninstall\<your productcode>\DisplayVersion or something similar

 

or even simpler, just run it and catch a 1638 exit code (indicating another version is already installed)

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ