For command ?

  • Thread starter Thread starter Larry
  • Start date Start date
L

Larry

Could someone tell me if I can put more than one command in a for statement?
I would like my output to be on one line i.e.


machinename username etc.
 
Larry said:
Could someone tell me if I can put more than one command in a for statement?
I would like my output to be on one line i.e.


machinename username etc.
your subject is nearly correct for getting help
for /?

You may group several commands in distinct lines by putting parenthes
around.
You may echo several values on one line, and with set /P you echo
information without a crlf.

@echo off
for %%A in (one two three) do (
set /P ="%%A - " <nul
Rem just to show grouping
)
echo four


HTH
 
What I wanted to do was:

dump a registry key using reg, the output will look like this:

alertdirectory reg_sz \\computername\vpalert$

then as part of that place the users computername on the same line so it
would look like this:

mycomputer \\computername\vpalert$

if I could have everything, I would get this:

mycomputer computername username

Help?

thx sir,...
 
Larry said:
What I wanted to do was:

dump a registry key using reg, the output will look like this:

alertdirectory reg_sz \\computername\vpalert$
Hello Larry,

IMO this is totally different from your initial posting and from your
subject.
then as part of that place the users computername on the same line so
it would look like this:

mycomputer \\computername\vpalert$

if I could have everything, I would get this:

mycomputer computername username
Do you want to know how to filter the reg output to the computername
from that line starting with alertdirectory ?
 
This is the syntax:

for /f "skip=2 usebackq tokens=3" %%a in (`reg query
"hklm\software\intel\landesk\virusprotect6\currentversion" /v
alertdirectory`) do (set Navserver=%%a)

what the above will do is set an environment var. to the current nav
server. However, the output looks like this:

\\servername\vpalert$

this is our norton signature file server. What I want is to remove the
\\ and the vpalert$ from the output... Does that help?

thx,..
 
Larry said:
This is the syntax:

for /f "skip=2 usebackq tokens=3" %%a in (`reg query
"hklm\software\intel\landesk\virusprotect6\currentversion" /v
alertdirectory`) do (set Navserver=%%a)

what the above will do is set an environment var. to the current nav
server. However, the output looks like this:

\\servername\vpalert$

this is our norton signature file server. What I want is to remove the
\\ and the vpalert$ from the output... Does that help?

thx,..

Try this, IMO usebackq is unneccessary.

for /f "skip=2 tokens=3 delims=\ " %%A in (
'reg query "hklm\software\intel\landesk\virusprotect6\currentversion" /v alertdirectory'
) do set Navserver=%%A

Multiple adjacent delims are ignored so the addition of the backslash
should return only the servername.

HTH
 
@echo off
setlocal
Set regq="hklm\software\intel\landesk\virusprotect6\currentversion" /v
alertdirectory
for /f "Tokens=2 Delims=\" %%a in ('reg query %regq%^|Findstr /C:"REG_SZ"') do (
set server=%%a
)
@echo %ComputerName% %server% %UserName%
endlocal



What I wanted to do was:

dump a registry key using reg, the output will look like this:

alertdirectory reg_sz \\computername\vpalert$

then as part of that place the users computername on the same line so it
would look like this:

mycomputer \\computername\vpalert$

if I could have everything, I would get this:

mycomputer computername username

Help?

thx sir,...


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Matt, one more question and we can consider this thread closed. I am getting
mixed results with the quotes and there orientation. i.e. ` compared to ',
not sure why this sometimes works and other times it wont. The error is
cannot find `reg.exe
 
Larry said:
Matt, one more question and we can consider this thread closed. I am getting
mixed results with the quotes and there orientation. i.e. ` compared to ',
not sure why this sometimes works and other times it wont. The error is
cannot find `reg.exe
Larry did you copy my suggestion to your batch ?

Note, when you omit usebackq you've to use the ' as delimiter not the `
And they must both be the (' command ') same to form a valid command.

Functional Jerolds solution should be equivalentg. Did that work ?

HTH
 
yes I went with your suggestion and everything is working. However, another
person I work with said they could not use it because of the error below.
However, all of our users are running fine. I was just curious about the
significance of that parameter "usebackq". I do appreciate you hanging there
Matt. Don't go away though, I am posting another question.

thx again, appreciate your help...

Larry
 
Back
Top