Last active
November 19, 2024 15:51
-
-
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 hidden or 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
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!