Execute Bat File on Remote Windows Host with Zabbix Agent
For pre Zabbix 5.02. In the zabbix_agentd.conf for the remote host, add EnableRemoteCommands=1 and then restart the agent process.
In Zabbix 5.0 and 5.01, you will also need to comment out the DenyKey parameter which blocks system.run by default, and then restart the agent process.
In Zabbix 5.02 and later, you can ignore EnableRemoteCommands=1 since it is now deprecated, and you should use a combination of DenyKey and AllowKey to fine tune the scripts you want to deny/allow.
See Restricting agent checks for more info.
In this video, I create a bat file that backups a file. I then execute it and read the response from the remote Zabbix Agent host using the system.run item key.
@echo off COPY c:\temp\abc.txt c:\temp\123.txt >nul && (echo 1) || (echo 0)