Why is my batch script freezing? (windows 7)

bertstares

New member
Local time
9:50 PM
Messages
2
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

Computer type
PC/Desktop
OS
64
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[COLOR="Red"].exe[/COLOR] /v /fo csv | findstr Ethernet"') do echo %%a
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Wow, I feel so stupid right now. The name of my file was Getmac. Thank you so much, everything works now.
 

My Computer

Computer type
PC/Desktop
OS
64
Back
Top