Last active
June 25, 2018 00:18
-
-
Save redfellow/cfd128e2601436f46f126d523ddc87b7 to your computer and use it in GitHub Desktop.
Windows 10: Bind and start transmission-daemon on specific NIC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set IP="" | |
for /f "tokens=2 delims==" %%F in ('wmic nic where "NetConnectionStatus=2 and AdapterTypeId=0" get NetConnectionID /format:list') do set interfaceName=%%F | |
if "%interfaceName%"=="PIA VPN" ( | |
for /f "tokens=1-6 delims=:. " %%a in ('netsh int ip show address "PIA VPN" ^|find "IP Address"') do set IP=%%c.%%d.%%e.%%f | |
if defined IP ( | |
echo VPN IP check OK: %IP% -- Starting transmission | |
"C:\Program Files\Transmission\transmission-daemon.exe" --foreground --config-dir J:\apps\transmission --bind-address-ipv4 %IP% | |
) else ( | |
echo "VPN IP check FAIL: %IP% -- Exiting script" | |
) | |
) else ( | |
echo VPN Interface is not connected, current active interface is: %interfaceName% -- Exiting script | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script requires that your VPN Adapter is named
PIA VPN
(modify the script or rename your adapter).You'll also probably want to modify the path to transmission executable and the transmission config file on row 10.