We will soon be rolling out full disk encryption software to all laptops and our supplier have advised us to ensure all machines that require a defrag, are defragged. So with that in mind, we created a custom LANDesk script to, initially, defrag analyse each machine and pipe the logfile to a server share as follows:-

The defrag analysis works fine but the logfile is not created on the server share. We've checked NTFS permissions and also changed the command line to created the logfile locally (for testing purposes) but still the custom script will not create the logfile:-

[MACHINES]remexec0=defrag c: -a -v >C:\%computername%.log

We have also manually run the command line in a cmd prompt running as the LocalSystem account to emulate a LANDesk script/package and it does work. So why does it not work within our LANDesk custom script please?

The logfile is created on the server share but the package fails on the server with the message "the system cannot find the path specified". Nornmally, I'd be able to resolve this seemingly simple issue but it has baffled me this time. I can access the server path from the client, not that I should need to because the package created the logfile on the server share (!).

We're still perplexed as to why we can run the batch files fine but when deploying as a LANDesk package the final status message is "the system cannot find the specified file", despite the batch file running successfully (!!!).

Not ideal but to overcome this, we appended EXIT /B 0 to the end of the script to force the final status message to "Done - No error". So far so good...