@echo off


sc query "Zabbix Agent" > null

if  not %errorlevel%==0 (
	echo install zabbix service
	c:\zabbix_agents_3.4.6.win\bin\win32\zabbix_agentd.exe --config C:\zabbix_agents_3.4.6.win\conf\zabbix_agentd.win.conf --install
	echo start zabbix service
	net start "Zabbix Agent"
	echo set  zabbix service auto
	sc config "Zabbix Agent" start= auto
	echo open firewall for zabbix
	netsh advfirewall firewall add rule name="Zabbix" dir=in program="c:\zabbix\bin\zabbix_agentd.exe" action=allow
	pause
) else (
	echo Zabbix Agent is already installed, it will be reinstalled!
	net start|find "Zabbix Agent" >null
	if %errorlevel%==0 (
	net stop "Zabbix Agent"
	)
	sc delete "Zabbix Agent"
	c:\zabbix_agents_3.4.6.win\bin\win32\zabbix_agentd.exe --config C:\zabbix_agents_3.4.6.win\conf\zabbix_agentd.win.conf --install
	echo start zabbix service
	net start "Zabbix Agent"
	echo set  zabbix service auto
	sc config "Zabbix Agent" start= auto
	echo open firewall for zabbix
	netsh advfirewall firewall add rule name="Zabbix" dir=in program="c:\zabbix\bin\zabbix_agentd.exe" action=allow
	pause 
)



