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 7693149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:01:03+00:00 2026-05-31T21:01:03+00:00

This ended up being a path issue. I was using path as one of

  • 0

This ended up being a path issue. I was using “path” as one of my variables elsewhere in the script without realizing that this actually edited the environment variable PATH.

Original question:

I am writing a batch file. In the batch file I have the following:

FOR /F "tokens=*" %%a IN ('git branch -r') DO CALL :SOMELABEL %%a

EXIT

:SOMELABEL
git status
START /B /WAIT CMD /C git status
FOR /F "tokens=*" %%n IN ('git status') DO ECHO %%n
GOTO :EOF

‘git status’ is just an example. Each of the 3 ‘git status’ commands return “‘git’ is not recognized as an internal or external command, operable program or batch file.”

Normally, this would be an environment variable issue (PATH), but what makes this unique is the fact that the first git command works (“git branch -r”). I have maybe 5 other batch files that can use the git command successfully as well. Any ideas as to why the later git commands won’t work in the code above?

If it’s due to a permissions issue (like can’t execute another git command while one is in progress sort of thing), any idea how I might make this script work (preferably without having to make a temporary file)? Or is making a temp file for the output of the first command the only way?

  • 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-05-31T21:01:04+00:00Added an answer on May 31, 2026 at 9:01 pm

    It should be a PATH issue, though.

    The OP Lectrode confirms:

    It was a path issue.
    I just realized that in my original script I was using path for one of my variables.
    I did not realize that was setting the environment PATH variable.

    Apparently git uses that “batch proxy” thing.
    The command works when you change git status to CALL git status.


    Original answer:

    I just tested the following script successfully, following the syntax described in “DOS Batch – Function Tutorial” (and using the ‘which’ command I installed through gow):

    @echo off
    echo.PATH=%PATH%
    which git.exe
    FOR /F "tokens=*" %%a IN ('git branch -r') DO CALL :myDosFunc %%a
    call:myDosFunc
    echo.&pause&goto:eof
    
    :myDosFunc    - here starts my function identified by it`s label
    echo. with param  %~1
    which git.exe
    git status
    goto:eof
    

    And it did returned, when executed within a Git repo on Windows:

    C:\prog\git\tests\my_repo>..\c.bat
    PATH=Z:\apps\git176\bin;...
    Z:\apps\git176\bin\git.exe
     with param  origin/master
    Z:\apps\git176\bin\git.exe
    # On branch master
    nothing to commit (working directory clean)
     with param
    Z:\apps\git176\bin\git.exe
    # On branch master
    nothing to commit (working directory clean)
    

    So it seems to work. (As pointed out by Magnus, I don’t use exit)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

=======UPDATE======== The problem ended up being that I was using the header ContentType when
I ended up writing a quick little script for this in Python, but I
I have a PHP script that is using wget to download some images. However,
This question ended up being more interesting than I thought it would be, and
Historical Context: This problem ended up being not at all what I thought it
I ended up with this horrible code below, I can't get a better result
This is a difficult and open-ended question I know, but I thought I'd throw
This question is a bit open ended as I'm not sure it's possible or
I hope this question isn't too open ended, but a nudge in the right
After some find and replace refactoring I ended up with this gem: const class

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.