Help on For command

N

New User

Hello:

I am trying to write a script the 2 "for" function. Can you kindly
help to point out what is the error?

for /f "tokens=3,4 delims=, " %a in ('
for %n in (`reg query HKCU\Printers\Connections`) do echo %n | find /i
"PSTT"
') do echo %a %b

I use this script to get the current printer server name & print queue
name from NT4, Win2K & WInXP.
"PSTT" is the print server name, full name is PSTTA01, PSTTD02.......

I think the problem is it have ` in both for loop.
Can you kindly give me suggestion?

Thanks!
 
J

Jerold Schulman

Hello:

I am trying to write a script the 2 "for" function. Can you kindly
help to point out what is the error?

for /f "tokens=3,4 delims=, " %a in ('
for %n in (`reg query HKCU\Printers\Connections`) do echo %n | find /i
"PSTT"
') do echo %a %b

I use this script to get the current printer server name & print queue
name from NT4, Win2K & WInXP.
"PSTT" is the print server name, full name is PSTTA01, PSTTD02.......

I think the problem is it have ` in both for loop.
Can you kindly give me suggestion?

Thanks!

Not sure what you are trying to accomplish. I suspect:

for /f "tokens=2* delims=," %a in ('reg query HKCU\Printers\Connections^|find /i "PSTT"') do echo %a %b

This is NOT a script. It is a command. If it were a script, then %a and %b would be %%a and %%b.

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 

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