使用psexec和wmic在批处理文件中逐行读取文本

时间:2016-08-03 04:01:14

标签: batch-file psexec wmic

我有像所有ip一样的test.txt文件。 (例如:)

  

192.168.xxx.50

     

192.168.xxx.51

     

192.168.xxx.52

     

192.168.xxx.53

     

192.168.xxx.54

     

192.168.xxx.55

我想使用psexec制作批处理文件,wmic使用那些IP

FOR /F "tokens=* delims=," %%i in (test.txt) do (
psexec \\<i dont know how to do in here..it should be ip in here each line>-u <domain>\administrator -p <password> wmic /output:\\<serverip should be here which is going to save>\d$\%(i want this each ip info)%.txt product get name,vendor
) 

怎么办..?我想我不知道%%参数

1 个答案:

答案 0 :(得分:1)

Wmic可以在没有PSExec帮助的情况下完成此操作。您的文件格式正确为wmic。

wmic /node:@"Computerlist.txt" product get name,vendor /format:htable

请参阅wmic /node /?wmic /format /?

开始 - 所有程序 - 附件 - 右键单击​​命令提示符和 选择以管理员身份运行键入(或通过右键单击进行复制和粘贴 在命令提示符窗口中,选择粘贴)。表格格式的类型

wmic /output:"%userprofile%\desktop\WindowsInstaller.html" product get /format:htable

或表格格式

wmic /output:"%userprofile%\desktop\WindowsInstaller.html" product get /format:hform

它将在桌面上创建一个html文件。

注意

这不是完整列表。这只是与Windows Installer一起安装的产品。一切都没有特色。

但正如我在上一篇文章中所述,几乎所有内容都列在注册表中。

所以要在命令提示符下看到它

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s

或在文件中

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s>"%userprofile%\desktop\WindowsUninstall.txt"

以不同的格式在记事本中查看

单击开始 - 所有程序 - 附件 - 右键单击​​命令提示符,然后选择以管理员身份运行。键入Regedit并导航到

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

右键单击“卸载”键,然后选择“导出”。如果您保存为reg文件(还有文本文件,它们的文本格式略有不同),您需要右键单击该文件并选择“编辑”进行查看。

查看Windows更新

wmic /output:"%userprofile%\desktop\WindowsUpdate.html" qfe  get /format:htable