KACE Product Support Question

Kcleanup Really Slow with 3.6

06/19/2014 3795 views

Since the 3.6 update the kcleanup task takes excessively long. 

After our image deploys I have 3 post install tasks one to Join the domain and then,one to activate windows and one to activate office. All these tasks run fine and kcleanup starts after them. A black command prompt window comes up for kcleanup.exe and then it just sits there for a really long time like 20 to 30 minutes. Eventually it does work and the computer restarts and all the KACE files get properly deleted. But 30 minutes on that screen is ridiculous, that doubles my imaging time. 

Anyone run into this before?
Answer Summary:
0 Comments   [ + ] Show comments


All Answers

that task takes me seconds usually.  it is this vbs script.  maybe you need to do a chkdsk on your master or have other problems with it.

vbs file:

Dim objShell, cmd, errorCode, regKeyOsVersion, osVersion, version, osh, engineKey, value

Function GetOSVersion()
    regKeyOsVersion = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentVersion"
    osVersion = objShell.RegRead(regKeyOsVersion)
    GetOSVersion = osVersion
End Function

Function ServerIp()

    Dim xmlDoc, configFile, expandedPath, serverNode

    set osh      = CreateObject("WScript.Shell")
    set xmlDoc   = CreateObject("Msxml2.DOMDocument")
    configFile   = "%systemdrive%\KACE\Engine\Config.xml"
    expandedPath = osh.ExpandEnvironmentStrings(configFile)


    set serverNode = xmlDoc.SelectSingleNode("//Config/HostServer")
    ServerIp = serverNode.Text

End Function

Function DeploymentType()

    Dim xmlDoc, configFile, expandedPath, serverNode

    set osh      = CreateObject("WScript.Shell")
    set xmlDoc   = CreateObject("Msxml2.DOMDocument")
    configFile   = "%systemdrive%\KACE\Engine\Config.xml"
    expandedPath = osh.ExpandEnvironmentStrings(configFile)


    set serverNode = xmlDoc.SelectSingleNode("//Config/DeploymentType")
    DeploymentType = serverNode.Text

End Function

Function SystemImageId()

    Dim xmlDoc, configFile, expandedPath, serverNode

    set osh      = CreateObject("WScript.Shell")
    set xmlDoc   = CreateObject("Msxml2.DOMDocument.6.0")
    configFile   = "%systemdrive%\KACE\Engine\Config.xml"
    expandedPath = osh.ExpandEnvironmentStrings(configFile)

    xmlDoc.async = false

    set serverNode = xmlDoc.selectSingleNode("//Config")
    SystemImageId = serverNode.getAttribute("DeploymentId")

End Function

Sub PushDeploymentInfo()

    Dim server_ip, image_id, deployment_type, fetch_url, file_path, http_handle, file_handle, file_handle_handle

    server_ip       = ServerIp()
    image_id        = SystemImageId()
    deployment_type = DeploymentType()

    If deployment_type = "SI" Then
        fetch_url   = "http://" & server_ip & "/rpc/k1000_inventory.php?boot_image_id=" & image_id
        fetch_url   = "http://" & server_ip & "/rpc/k1000_inventory.php?system_image_id=" & image_id
    End If

    set http_handle = CreateObject("Microsoft.XmlHttp")

    http_handle.open "GET", fetch_url, FALSE

    file_path = "C:\ProgramData\Dell\KACE\k2000_deployment_info.conf"
    set file_handle = CreateObject("Scripting.FileSystemObject")
    set file_handle_handle = file_handle.CreateTextFile(file_path, True)
    file_handle_handle.Write http_handle.responseText

End Sub
' Multipurpose object thing ...
Set objShell = CreateObject("WScript.Shell")
' Delete the task engine run key if it exists, then, assert the Dell\KACE directory
On Error Resume Next

engineKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\KACETaskEngine"
value = WSHShell.RegRead(engineKey)

If err.number = 0 Then
    objShell.RegDelete engineKey
End If

cmd = "cmd /c md ""%allusersprofile%\Dell\KACE"""
errorCode = objShell.Run(cmd, 0, True)
' Has to run prior to kcleanup
call PushDeploymentInfo()
' Check for Windows 8
version = GetOSVersion
If Left(Version,3) >= "6.2" Then
    objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell", "explorer.exe", "REG_SZ"
End If

cmd = "cmd /c start /wait c:\kcleanup.exe"
errorCode = objShell.Run(cmd, 0, True)

cmd = "cmd /c del C:\kcleanup.exe /f"
errorCode = objShell.Run(cmd, 0, True)

Answered 06/19/2014 by: SMal.tmcc
Red Belt

  • chkdsk on the image looks fine. I'm guessing since I get stuck on the kcleanup.exe the issue is with it that file. The vbs should be running fine since it get up to that point fast.
    • Also do I have to initiate my own restart? I don't have a restart task setup after all my post install tasks run. I didn't think that was required since it usually restarts on its own after all the tasks run.
      • the cleanup will restart for you
    • when it reboots, be ready and boot into safe mode so no 3rd party programs run including kcleanup.

      See if this take a long time, if yes then it is a system file problem.

      Use regedit and go to the runonce key and turn off the kcleanup task and reboot so all other third party apps run and see if it is slow.

      Then manually run the vb line you remove from the run once.

      this should help you narrow it down to what is causing the lag. it could be driver discovery happening or some other program doing tasks which are delaying the kcleanup, or just be something wrong with the cleanup task for your image.
      • ok so safemode after the image deploys? Also I checked a few machines that had kcleanup running and they all had kcleanup.exe in the task manager running at 50% CPU. Don't know if that's a clue to anything.
      • tap f8 as it reboots prior to kcleanup running and choose safe mode and remove the run command for kcleanup from the registry
We found that SEP was causing the problem.
We added an exception to SEP policy to exclude the KACE directories and the cleanup task went back to a few seconds
Answered 06/19/2014 by: Gavio
White Belt

  • We are running SEP so I bet you this is the issue. Is there anyway to add the exclusion to the image without having to recreate them? Through the registry maybe with a post install task?
    • We use a scripted installation. When SEP installs it updates its policy from the
      SEP Manager which has the exclusion.
      We excluded c:\kace\ and c:\kcleanup.exe.
      Try adding the exclusions and see if when you image SEP updates policy.
      I believe running the following forces a heartbeat which will update policy
      smc.exe -updateconfig
      The exclusions are in the registry so you could add them
      but much better off letting policy do it.


      • I added the exclusion to the SEP Manager but it didn't seem to work. Maybe because since I have a WIM image. So I just setup a post install task to shut off SEP right at the start. kcleanup is almost instant right after that and SEP turns back on automatically on the restart. Seems like our issues are fixed. Thanks a ton Gavin!
  • Dan - Can you elaborate on the postinstall tasks you created to shut off / turn on SEP to improve kcleanup process? I'm a scripting noob and could really use some guidence.

    • Hey Paul. Disabling Symantec is a simple one liner ran as a BAT script. "C:\Program Files\Symantec\Symantec Endpoint Protection\smc" -stop Symantec automatically turns back on after the machine restarts.
      • Thanks for the response - I'll give it a shot
      • Also worth noting, most enterprises run SEP with a password. In the documentation from Symantec they say to call the commands as such: "...\smc" -stop -p XXXXXXX
        That didn't work for us. What we had to do was call the password before the stop command like this: "...\smc" -p XXXXXXXX -stop

        I hope this helps save others time trying to get that working, or rather, stopping.

Don't be a Stranger!

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

Sign up! or login


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