Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:09:31+00:00 2026-06-06T16:09:31+00:00

Note: I have almost no idea at all how batch file ‘for’ loops work.

  • 0

Note: I have almost no idea at all how batch file ‘for’ loops work.

The batch file I have currently:

"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’m trying to write a robust IP changer that utilizes HMA! Pro VPN – it should work whether the VPN client has been opened or not, and whether the VPN is currently opened or not, and should pause until the VPN has connected.

If you Google the for loop, you’ll see it appear in a stackoverflow answer – this for loop works perfectly fine in a CMD prompt, and sets %state% to Connected/Disconnected well, but in a batch file, throws the following error:

D"=="Local was unexpected at this time.

I would learn more about for loops in batch had I not been under a very tight schedule – I have learnt about these before, but this loop looks pretty weird to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:09:32+00:00Added an answer on June 6, 2026 at 4:09 pm

    In a batch file you have to use two percents for FOR parameters, that’s all

    for /f "usebackq tokens=1,2,3,*" %%A in (`netsh interface show interface`) do (
        if "%%D"=="Local Area Connection 2" set state=%%B
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A calculator program I have created works almost perfectly with the exception that Math.Sin()
there i have created a program with a tab button and page number. all
NOTE: I have read Routing From the Inside Out AND the Engine Yard blog
NOTE: I have solved the majority of this problem but have run into a
Note: I have given up on compiling iPhone Apps without a developer certificate for
Note I have completely re-written my original post to better explain the issue I
I have a note and it has a certain number of attributes. It also
(Please note that I have seen a similar question on StackOverflow recently, however I
Note - I do not have access to a database and cannot use PHP,
i have a recursive query like this (note: this is just an example): var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.