How to deploy CMD file


Hi. I have a CMD script file. How to deploy it using policy? I think I need a command line. 


Best answer by JohnG-Automox 19 May 2023, 21:41

View original

3 replies

Userlevel 3

Hi @jaykim!

You can use a Worklet for deploying a batch or CMD script file!


Since Automox Worklets use Powershell syntax, you’ll need to upload the cmd or batch file to the payload of the worklet, and then call the file through Powershell in the Remediation Code.

Here is a quick example of running a cmd file from a Worklet:

exit (Start-Process -FilePath ".\BatchFile.cmd" -WindowStyle Hidden -Wait -Passthru).ExitCode

Be sure to replace BatchFile.cmd with the name of the file you upload to the Worklet’s payload:


I hope this helps!

Have a great weekend!


Thank you for the response. How about the Scope area? Use the same code for the Scope and Remediation Code? 

Userlevel 3

A Worklet’s Evaluation Code is used to test a condition on a device, and then trigger the Remediation Code depending on the Exit status. An Exit 0 means the device is complaint and does not need Remediation. Any non-zero Exit value (Exit 1 for example) means the the device is not complaint and will flag the device for Remediation.

With that being said, if you don’t have any Evaluation logic you wish to use, you can pass an Exit 1 and this will flag the device as not compliant and in need of Remediation.


Evaluation Code:

Exit 1

Remediation Code:

exit (Start-Process -FilePath ".\BatchFile.cmd" -WindowStyle Hidden -Wait -Passthru).ExitCode


You can read more about how to use Worklets here:

I also recommend checking out our Automox University for some great guided courses for using Worklets: