Batch file

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

I have wrote the simplest of batch files which contains
the lines:>

psinfo -h -s \\192.168.81.7 >audit.txt
psinfo -h -s \\192.168.81.8 >>audit.txt
psinfo -h -s \\192.168.81.9 >>audit.txt

(this does it for a whole ip range)

basically psinfo is a tool to audit pc's H/W and S/W on a
network. The -h displays hotkeys and -s is software.

The problem i get is when i run the batch file it runs as

psinfo -h -s \\192.168.81.7 1>audit.txt
psinfo -h -s \\192.168.81.8 1>>audit.txt
psinfo -h -s \\192.168.81.9 1>>audit.txt

Somehow it is inserting a 1 which is causing an error. If
i manually type the line in however the 1 does not appear!
I have 255 nodes to scan so the batch file would be a big
help. Any suggestions to this mysterious 1?!?
 
Lee said:
I have wrote the simplest of batch files which contains
the lines:>

psinfo -h -s \\192.168.81.7 >audit.txt
psinfo -h -s \\192.168.81.8 >>audit.txt
psinfo -h -s \\192.168.81.9 >>audit.txt

(this does it for a whole ip range)

basically psinfo is a tool to audit pc's H/W and S/W on a
network. The -h displays hotkeys and -s is software.

The problem i get is when i run the batch file it runs as

psinfo -h -s \\192.168.81.7 1>audit.txt
psinfo -h -s \\192.168.81.8 1>>audit.txt
psinfo -h -s \\192.168.81.9 1>>audit.txt

Somehow it is inserting a 1 which is causing an error. If
i manually type the line in however the 1 does not appear!
I have 255 nodes to scan so the batch file would be a big
help. Any suggestions to this mysterious 1?!?

If you explain the error we might be able to help.

The insertion of the 1 is normal, it it done by cmd.exe when it
parses your script. It just means redirect stdout to wherever.
If it really bothers you change the line to:-
audit.txt psinfo -h -s \\192.168.81.7

If your seeing errors, then they're not being caused by the '1'.

I recommend you read the FOR command's helpfile, in particular
the section regarding the /L switch - it could save you a lot of
typing.
 
I take it psifo is another batchfile or some other program?

Are you sure you need to have those slashes in front of
the IP address?

I suggest you use the FOR command to crawl the IP range
like so:

:: start

echo. > audit.txt
FOR /L %%i IN (1,1,254) DO @psinfo -h -s 192.168.81.%%i >>
audit.txt

:: end
 
I see what you mean by the 1 in front of the >. It does
still write it to the file though. The only thing I can
see doing is to set up your batch file without
individually sending each command to a file. Then call the
batch file from the command prompt and there pipe it to a
file.
 
Back
Top