Skip to content

Instantly share code, notes, and snippets.

@redfellow
Last active November 19, 2024 15:51
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
)
@NoodleMunkee
Copy link

I know this is 6 years old, but I just came across a need for this exact script, and you saved me tons of time!

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