/build/static/layout/Breadcrumb_cap_w.png

KACE: Defrag Script That Can Be Run On 32-Bit and 64 Bit Systems

Summary:  Some users have reported that using a script on 64 bit to defrag clients do not run.  Our agent is currently a 32-bit and KACE is working on a 64-bit version.  Find below a script that will run on both:

Copy/paste the below info into a new script by doing the following: 

  1. Scripting > Scripts > Choose Action > Import from XML
  1. Paste below info in
  1. Save script

 

 

<?xml version="1.0" encoding="utf-8" ?>

<kbots xmlns="http://kace.com/Kbots.xsd">

<kbot>

 

<config name="CUSTOM - Defragment the C: drive" type="policy" id="114" version="1327423077" description="Script to defragment the c: ">

 

  <execute disconnected="true" logged_off="true">

  </execute>

 

</config>

 

<compliance>

 

  <verify on_failure="break" attempts="1">

 

    <directory_exists path="&quot;C:\Program Files (x86)\&quot;" />

 

    <on_verify_success>

      <launch_program path="$(KACE_SYS_DIR)" program="cmd.exe" wait="true" parms="/C start /wait %Windir%\Sysnative\defrag.exe C: -f " />

      <log_message type="status" message="Defrag Issued Successfully." />

    </on_verify_success>

 

    <on_verify_failure>

      <log_message type="output" message="Not 64 bit system" />

 

      <on_remediation_success>

        <launch_program path="$(KACE_SYS_DIR)\" program="cmd.exe" wait="false" parms="/C start /wait %SYSTEMROOT%\system32\defrag C: -f" />

      </on_remediation_success>

 

      <on_remediation_failure>

      </on_remediation_failure>

 

    </on_verify_failure>

 

  </verify>

 

</compliance>

 

</kbot>

</kbots>

 


Comments

  • Hi

    This doesn't seem to work on a Windows 7 64 bit PC.

    Cmd.exe runs but then cannot find 'C:\Windows\System32\Defrag' even though I can run defrag from the system32 folder manually? - LiamSinton 11 years ago
  • After hours and hours of testing, the reason that this script fails on a 64 bit system is because of the presence of the verify task at the beginning.

    Don't ask me why but if you remove the verify task to verify that "C:\Program Files (x86)" exists, it runs fine on a 64 bit PC although I also changed the paths slightly to the following:

    Directory: %windir%\syswow64
    File: cmd.exe (wait for startup checked)
    Parameters: /C start "defrag" /wait %windir%\Sysnative\defrag.exe C: -f /U

    In the end, I just could not get a single script to work with both 32 and 64 bit PCs due to the lack of a 64 bit defrag.exe so I just created 2 scripts and used machine labels instead. - LiamSinton 11 years ago
This post is locked

Don't be a Stranger!

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

Sign up! or login

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