Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I dumped all the physical network GUIDs to a file via:

wmic nic where "PhysicalAdapter = 'TRUE'" get GUID > networkAdapterGUIDs.txt

When I try to read the file and echo out its contents nothing happens:

for /F "tokens=*" %%A in (networkAdapterGUIDs.txt) do echo %%A

I have tried %%A with .bat files and just %A when running on the command line.

Here's a screenshot of what I'm seeing:

http://puu.sh/6Geyn/c09d1ad079.png

If I could get a simple echo to work I later planned to do something with the lines that have the GUID on them and omit/skip the first line.

I launched up a fresh Windows 8.1 virtual machine and had the same experience. I am currently running Windows 8.

share|improve this question
    
cmd tools used to have (and obviously still have) problems with Unicode output produced by tools like wmic. Try to do simple type networkAdapterGUIDs.txt >fixed.txt (I think more also works but I'm not sure) and then run your loop over the 'fixed' file. If it helps I will put this as an answer –  wmz Feb 1 at 18:43
    
Found out that I could skip the file creation and just pass the command into for for /F %%x IN ('wmic nic where "PhysicalAdapter = 'TRUE'" get GUID') I'm still interested why I couldn't get it to read from a file though, although as you pointed out it could definitely be a file encoding problem –  CTS_AE Feb 1 at 18:49
    
I just tried what you said and that worked as well : ) thanks. wmic spit out UCS-2 Little Endian, and type spit out UTF-8 without BOM, checked with notepad++ That was going to drive me crazy; would have never question the file encoding. At that point I was sure that Windows 8 had some issues with its for loop file reading, glad to know it doesn't. –  CTS_AE Feb 1 at 18:55
    
just be careful as you may also get unexpected results when running wmic directly from within for (its output contains chars treated as control by batch engine) –  wmz Feb 1 at 18:57
    
Yeah I've been noticing that I'm having some issues with the empty line it throws in at the end even though I have the /F option –  CTS_AE Feb 1 at 19:27

1 Answer 1

up vote 1 down vote accepted

cmd tools used to have (and obviously still have) problems with Unicode output produced by tools like wmic. Try to do simple type networkAdapterGUIDs.txt >fixed.txt and then run your loop over the 'fixed' file

Rob van der Woude's page has also excellent section on those [conversions]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.