REM @echo off
REM ** PART1 - GET LIST OF PCS ON NETWORK **
NET VIEW > Working\Netview.txt
REM ** PART2 - TRIM LIST DOWN SO LEFT 20 CHARACTERS **
BIN\sed -e 's/^\(.\{20\}\).*/\1/' Working\Netview.txt > Working\Hostnames.txt
REM ** PART3 - NOW TRIM DOWN TO JUST COMPUTER NAMES **
rem BIN\fgrep -e \\ Working\Hostnames.txt > "Working\Hostnames2.txt"
Hostnames2.txt输出(缩短,列表更长)
\ ALASTAIR-MUNRO
\ ANDREW加德纳
\ ANDREWATKINSON
\ ANDY-KAYE
\ ANDYTURNER
\ BARRYWALL
\ CAD-SPARE1
我需要一个命令,我可以运行然后将“Psinfo -s”添加到每一行,所以我得到类似于下面的文本输出:
psinfo -s \ ALASTAIR-MUNRO
psinfo -s \ ANDREW-GARDNER
psinfo -s \ ANDREWATKINSON
任何想法???
由于
答案 0 :(得分:0)
执行:
@echo off
for /f "delims=" %%a in (hostnames2.txt) do psinfo -s %%a
或仅写入文件:
(for /f "delims=" %%a in (hostnames2.txt) do echo psinfo -s %%a)>output.txt
答案 1 :(得分:0)
这应该有效:
@echo off
set input=Hostnames2.txt
set output=commands.txt
type nul>commands.txt
FOR /F %%L IN (%input%) DO (
echo psinfo -s %%L>>%output%
)
如果您想逐个执行命令而不是将它们写入文件,只需跳过echo
和>>%output%
:psinfo -s %%L