Skip to content

Instantly share code, notes, and snippets.

@redfellow
Last active June 25, 2018 00:18
Show Gist options
  • Save redfellow/cfd128e2601436f46f126d523ddc87b7 to your computer and use it in GitHub Desktop.
Save redfellow/cfd128e2601436f46f126d523ddc87b7 to your computer and use it in GitHub Desktop.
Windows 10: Bind and start transmission-daemon on specific NIC
@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
)
@redfellow
Copy link
Author

redfellow commented Jun 25, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment