/build/static/layout/Breadcrumb_cap_w.png

Batch File to Uninstall KACE agent and Install a fresh copy - Help

I wrote a batch file.. not executed as a KACE script to look at a listing of hostnames that I know to have versions of the KACE agents prior to version 8.0. I'm using PSTools with it. It is suppoed to check the old Dell directories and the Quest directory for the existence of runkbot.exe and uninstall the KACE agent if it is there and copy the latest agent to the host and install the 8.0.152 version of the agent, and finally force the workstation to check in to the K1000. 

Batch file:

@ECHO OFF
Set PSExecDir=E:\pstools
Set InputFile=E:\scripts\badagent3.txt
Set OutputFile=C:\ScriptLogs\KACEAgentFix.txt
Set ErrorFile=C:\ScriptLogs\KaceError.txt

for /f %%a in (%InputFile%) do (

echo *** Checking Workstation %%a *** >> %OutputFile%

IF EXIST \\%%a\Progra~1\Dell\KACE\runkbot.exe GOTO DELL32
IF EXIST \\%%a\Progra~2\Dell\KACE\runkbot.exe GOTO DELL64
IF EXIST \\%%a\Progra~1\Quest\KACE\runkbot.exe GOTO QUEST32
IF EXIST \\%%a\Progra~2\Quest\KACE\runkbot.exe GOTO QUEST64

IF ERRORLEVEL 1 (echo There is a problem on %%a >> %ErrorFile%)
)

:DELL32
echo C:\Progra~1\Dell\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Dell\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO end

:DELL64
echo C:\Progra~2\Dell\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Dell\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END

:QUEST32
echo C:\Progra~1\Quest\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Program Files\Quest\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END

:QUEST64
echo C:\Progra~2\Quest\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END




:END


Here is the batch file output:


E:\scripts>kace_agent_fix.bat
C:\Progra~1\Dell\KACE DETECTED!

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access %a:
The network path was not found.

Make sure that the default admin$ share is enabled on %a.

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access %a:
The network path was not found.

Make sure that the default admin$ share is enabled on %a.

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                             
-------------------------------------------------------------------------------

  Started : Tuesday, June 12, 2018 2:49:47 PM
2018/06/12 14:49:47 ERROR 53 (0x00000035) Getting File System Type of Destination \\%a\C$\Temp\
The network path was not found.

   Source : E:\Scripts\AmpAgent\
     Dest - \\%a\C$\Temp\

    Files : *.*

  Options : *.* /DCOPY:DA /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

2018/06/12 14:49:47 ERROR 53 (0x00000035) Accessing Destination Directory \\%a\C$\Temp\
The network path was not found.
Waiting 30 seconds...^CTerminate batch job (Y/N)? y

E:\scripts>

I killed the batch file as it got stuck waiting. I can easily connect to the first PC in the list, ping it, connect to its admin share etc.  

Can anyone help me out here? 


0 Comments   [ + ] Show comments

Answers (1)

Posted by: Hobbsy 6 years ago
Red Belt
0
So many questions, is there a reason why you just didn't allow the KACE box to manage your upgrade? I am guessing at what the issue is, we face a similar challenge when upgrading customers from say 6.4 to 8.x, it becomes difficult to upgrade the agent alongside as that will take time using the KACE agent upgrade functionality. We came up with this, we create a script to uninstall the agent, that looks at the varieties ii.e. Dell/Quest and runs the uninstallation, usually for a week before we upgrade. This in effect orphans every device that is connected. We then setup a new GPO to install the 8.x agent, so once the upgrade of the box is complete, as machines connect, they get the new agent.

This logic could also be applied to the removal of the agent if the GPO's are configured in the correct way.

I also know this isn't an Answer but it was way too long to stick in the Comments area ;o)

Comments:
  • #1 - We have some bad agents in our environment and was told by Quest to remove them, hampering performance of the K1000.
    #2 - GPO does the initial agent install on fresh PCs

    We are basically trying to perform a clean up, as there are over almost 400 hosts that are out of regulation. - jayrobinson 6 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
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