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:
- Scripting > Scripts > Choose Action > Import from XML
- Paste below info in
- 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=""C:\Program Files (x86)\"" />
<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>
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 12 years ago
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 12 years ago