FOR command does not work when a command is used to generate the (set).

M

Marshall Buhl

Hi,

My FOR command does not seem to work properly. I've tried this example from
the Windows help on the FOR command. On other PCs, it works just fine.
Here's what happens on my broken PC:

---
D:\Temp>for /F "usebackq delims==" %i IN (`set`) DO @echo %i
'set' is not recognized as an internal or external command,
operable program or batch file.
---

This should generate a list of environment variables as it does here on
another machine:

---
D:\Temp>for /F "usebackq delims==" %i IN (`set`) DO @echo %i
ALLUSERSPROFILE
APPDATA
<snip>
---

No matter what command I put between the back quotes, it fails. It can be a
shell command such as DIR or an executable file. When I enter just the SET,
DIR, or the executable at the command prompt, they work just fine.

It's not the FOR statement that is broken. It does work when I specify a
file for the (set) and specify tokens .

I have spent most of the day searching the web for help, but found nothing
useful. Help would be greatly appreciated.


Marshall
 
P

Phil Robyn

Marshall said:
Hi,

My FOR command does not seem to work properly. I've tried this example from
the Windows help on the FOR command. On other PCs, it works just fine.
Here's what happens on my broken PC:

---
D:\Temp>for /F "usebackq delims==" %i IN (`set`) DO @echo %i
'set' is not recognized as an internal or external command,
operable program or batch file.
---

This should generate a list of environment variables as it does here on
another machine:

---
D:\Temp>for /F "usebackq delims==" %i IN (`set`) DO @echo %i
ALLUSERSPROFILE
APPDATA
<snip>
---

No matter what command I put between the back quotes, it fails. It can be a
shell command such as DIR or an executable file. When I enter just the SET,
DIR, or the executable at the command prompt, they work just fine.

It's not the FOR statement that is broken. It does work when I specify a
file for the (set) and specify tokens .

I have spent most of the day searching the web for help, but found nothing
useful. Help would be greatly appreciated.


Marshall

You don't need 'usebackq'.

for /f "delims==" %i in ('set') do @echo %i
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top