Execute Bat File on Remote Windows Host with Zabbix Agent
Zabbix Agents pre 5.02. In the zabbix_agentd.conf for the remote host, add EnableRemoteCommands=1 and then restart the agent process.
Zabbix Agents 5.0 and 5.01. Comment out the DenyKey parameter which blocks system.run by default, add EnableRemoteCommands=1 and then restart the agent process.
Zabbix Agents 5.02 and later. Either,
Comment out the DenyKey and add AllowKey=system.run[*]
or Comment out the DenyKey and add EnableRemoteCommands=1 (EnableRemoteCommands is now deprecated so it is no longer recommended and will eventually stop working as versions are updated)
See Restricting agent checks for more info.
To get the version of the agent on Windows, open a CMD prompt in the folder containing zabbix_agentd.exe and run
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)