gpt4 book ai didi

VBA查找远程计算机的安装日期和Bios日期

转载 作者:行者123 更新时间:2023-12-02 13:08:28 26 4
gpt4 key购买 nike

我正在尝试让一些 VBA 代码返回计算机 Ping 结果、安装日期和 BIOS 版本(以获取日期)。

For i = 1 To lRow
Debug.Print i
addr1 = ActiveSheet.Cells(i, 1).Value 'this contains my IP/Computer Name

cmdPing = "C:\Windows\System32\PING.EXE " & addr1
Set shPing = CreateObject("Wscript.shell")
Set runPing = shPing.exec(cmdPing)
strPing = runPing.stdout.readall
ActiveSheet.Cells(i, 2).Value = strPing
Set runPing = Nothing
Set shPing = Nothing

cmdInstall = "systeminfo /s " & addr1 & " | findstr /C:""Install Date"""
Set shInstall = CreateObject("Wscript.shell")
Set runInstall = shInstall.exec(cmdInstall)
strInstall = runInstall.stdout.readall
ActiveSheet.Cells(i, 3).Value = strInstall
Set runInstall = Nothing
Set shInstall = Nothing

cmdBios = "systeminfo /s " & addr1 & " | findstr /C:""BIOS Version"""
Set shBios = CreateObject("Wscript.shell")
Set runBios = shBios.exec(cmdBios)
strBios = runBios.stdout.readall
ActiveSheet.Cells(i, 4).Value = strBios
Set runBios = Nothing
Set shBios = Nothing

Next i

Ping 工作正常,但系统信息短暂闪烁并消失。我可以只使用 "systeminfo/s "& addr1 运行,但显然这会带来很多不必要的信息。我有一种感觉,这与传递 " 字符有关。也尝试过 /C:"& Chr(34) & " 但无济于事。

最佳答案

cmdInstall = "%comspec% /c systeminfo /s " & addr1 & " | findstr /C:""Install Date"""

cmdBios = "%comspec% /c systeminfo /s " & addr1 & " " & Chr(124) & " findstr /C:""BIOS Version"""

关于VBA查找远程计算机的安装日期和Bios日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22633787/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com