Why is my batch script freezing? (windows 7)


  1. Posts : 2
    64
       #1

    Why is my batch script freezing? (windows 7)


    This is not the entire script but this the line that is freezing, i'm just trying to compile some basic information from the computers in my domain with this login script.

    When running just this line as a bat file it will hang until closed and when you attempt to close CMD it lags up and displays a bunch of C^C^C^C^ before doing so.

    for /f "tokens=3 delims=," %%a in ('"getmac /v /fo csv | findstr Ethernet"') do echo %%a


    This command works perfectly when pasted into CMD prompt so why does it freeze when I make into in a .bat ?

    also inserting exit at the end does not help, the script never gets past this command and just hangs there.
      My Computer


  2. Posts : 721
    Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
       #2

    Hello Bertstares,

    Given the clues you've provided, it seems that the name of your batch file conflicts with that of an external command you are using in the problem command line you mention. I.e., you've managed to name your batch script either "getmac.bat" or "findstr.bat" (though I'm betting on the former).

    There are two solutions here: either you rename your batch file (preferably to something more verbose, such as "GetMacAddress.bat") so that it does not conflict with any of the names of the external commands you use in your batch program, or, if you wish to keep the name of your batch file as is, just append ".exe" to the command that is causing the naming confliction.

    E.g. If the name of your batch file is "getmac.bat" then append ".exe" to the Getmac command:
    Code:
    for /f "tokens=3 delims=," %%a in ('"getmac.exe /v /fo csv | findstr Ethernet"') do echo %%a
      My Computer


  3. Posts : 2
    64
    Thread Starter
       #3

    Wow, I feel so stupid right now. The name of my file was Getmac. Thank you so much, everything works now.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:41.
Find Us