Note. I hardly know how batch files work for loops.
The batch file that I have is:
"C:\Program Files (x86)\HMA! Pro VPN\bin\HMA! Pro VPN.exe" -connect "C:\Program Files (x86)\HMA! Pro VPN\bin\HMA! Pro VPN.exe" -changeip ping -w 2000 -n 1 1.1.1.1 :wait for /f "usebackq tokens=1,2,3,*" %A in (`netsh interface show interface`) do @if "%D"=="Local Area Connection 2" set state=%B if %state%==Connected goto :end goto :wait :end
I am trying to write a reliable IP changer that uses HMA! Pro VPN - it should work whether the VPN client has been opened or not, and whether the VPN is currently open or not, and should pause until the VPN connects.
If you use the for loop on Google, you will see that it appears in the stackoverflow answer - this loop works fine on the CMD command line and sets% state% to Connected / Disconnected very well, but it throws the following error in the batch file:
D"=="Local was unexpected at this time.
I would have learned more about cycles in batch mode if I hadn’t had a very limited schedule - I learned about this before, but this cycle looks rather strange to me.
source share