Why is this Windows batch not working:
@ECHO OFF
SET PATH="%PROGRAMFILES(x86)%\PuTTY";%PATH%
SET sti=%TEMP%\ipinfo_c200.txt
plink >nul 2>nul
IF %ERRORLEVEL% NEQ 9009 (
plink -ssh 192.168.1.101 -l root "wget -qO - http://ipinfo.io/ip" >%sti%
SET /P vpn=<%sti%
Del /F /Q %sti%
start "" http://%vpn%:8888/speedtest
) ELSE (
Echo Command plink does not exist. Install PuTTY.
)
EXIT
When this will work just fine:
@ECHO OFF
SET PATH="%PROGRAMFILES(x86)%\PuTTY";%PATH%
SET sti=%TEMP%\ipinfo_c200.txt
plink -ssh 192.168.1.101 -l root "wget -qO - http://ipinfo.io/ip" >%sti%
SET /P vpn=<%sti%
Del /F /Q %sti%
start "" http://%vpn%:8888/speedtest
EXIT
Only difference is the IF...ELSE.
When working inside the IF-statement the command plink does not return an IP address.
If I put the SET sti= statement inside the IF-statement I get an unexpected-error.
What am I missing (probably something basic)?
Thanks,