AutomoxAutomox

How to deploy CMD file

jaykim
May 18, 2023 at 6:54 pm UTC

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

This discussion is archived and closed to replies. Continue it in the Automox Community Slack.

Discuss on Slack

Replies (3)

JohnG-AutomoxMay 19, 2023
#1

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:

powershell1 line
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!

jaykimMay 19, 2023
#2

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

JohnG-AutomoxMay 19, 2023
#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:

powershell1 line
Exit 1


Remediation Code:

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

 

You can read more about how to use Worklets here:
https://help.automox.com/hc/en-us/articles/5352100773396-How-to-Use-Worklets

I also recommend checking out our Automox University for some great guided courses for using Worklets: https://university.automox.com/page/all-courses#topic_worklets