I want to create a (.bat) file to disable the port to which the device is attached. And the same file to include the port. (RouterOS 5.2).
I did something like this to create CMD files that change the VPN in use for a particular client. Attached is my file (without passwords) so you can get an idea.
Obviously this option has passwords in plaintext in files, but you can always use a more secure method to post the *.auto.rsc files to the router.
It seems to be impossible to upload cmd/bat files to the forum (for security I’d guess) so you have a header file like this for each VPN:
@Echo Off
set CHOSEN_VPN=ivpn-ca-ipsec
call CommonVPN.cmd
And then you have a CommonVPN.cmd which looks like this to write the commands and post them to the router:
@Echo Off
:: This file assumes that CHOSEN_VPN was set prior to this being called
:: Get my IP address
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
set ip=%ip:~1%
echo %ip%
::pause
:: Make me Whoever!
echo # Remove all the previous marks for this IP address, if there are any > RouterCommands.auto.rsc
echo :global ConnectIPToVpn >> RouterCommands.auto.rsc
echo :global AutoEnableDisableVPNs >> RouterCommands.auto.rsc
echo $ConnectIPToVpn IP="%ip%" VpnName="%CHOSEN_VPN%" >> RouterCommands.auto.rsc
echo # Now reset and restart any VPNs which might have changed >> RouterCommands.auto.rsc
echo $AutoEnableDisableVPNs >> RouterCommands.auto.rsc
C:\cygwin\bin\curl -v -T RouterCommands.auto.rsc ftp://UserChanger:password@192.168.90.1