windows - 根据系统信息调用 Web 请求
问题描述
好的,我想要的是一个脚本,它使用基于给定系统信息的调用 Web 请求命令。因此,假设我有两个不同的安装程序,一个用于 Nvidia gpu 系统,另一个用于 AMD gpu 系统,我已经可以使用另一个脚本获取 gpu 信息,并将其保存到 html 链接或文本文件,但我该如何使用这些信息,使用调用网络请求,下载正确的安装程序?
这是我用来获取 GPU 信息的 VB 脚本:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &"\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _ "SELECT *FROM Win32_VideoController",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_VideoController instance"
Wscript.Echo "-----------------------------------"
Wscript.Echo"Caption:"&objItem.Caption
Next
解决方案
您不需要混合搭配 VBS 和 PowerShell,PowerShell 完全能够自行查询 WMI!
用于Where-Object
根据Caption
值过滤结果,然后使用if
语句确定是否找到了每种类型中的任何一种:
$allVideoControllers = Get-CimInstance -Class Win32_VideoController
if($allVideoControllers |Where-Object Caption -like '*NVidia*'){
# Found an nvdia card, download and run the nvidia installer in here
}
if($allVideoControllers |Where-Object Caption -like '*AMD*'){
# Found an AMD card, download and run the AMD installer in here
}
推荐阅读
- azure - Xamarin Android 构建在 AppCenter (Azure) 中失败并出现错误 APT0000
- python - 分组数据处理后向数据框中添加新列时出错
- excel - vba excel中是否有选择要出现的excel窗口的代码?
- apache - 如何使用 Apache 在生产环境中运行 Mercure
- arrays - 从选择表单中保存数组值而不是索引
- mysql - 如何选择 - 更新然后将值复制到另一个表(批量)
- django - 姜戈。休息框架。嵌套关系空结果
- java - Android手机:如何使用Appium简单地打开应用程序而不安装(因为它已经安装)
- android - 片段微调器 onItemSelected 方法从未调用过
- javascript - 使用外部 Javascript 将图像添加到 HTML 画布