Help on For command

  • Thread starter Thread starter New User
  • Start date Start date
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!
 
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
 
Back
Top