我有一个使用WMIC(以及C#)调用SetBiosSetting方法的问题
wmic / namespace:\ root \ wmi path Lenovo_SetBiosSetting call SetBiosSetting“SecurityChip,Active”
wmic / namespace:\ root \ wmi path Lenovo_SetBiosSetting call SetBiosSetting SecurityChip,Active
wmic / namespace:\ root \ wmi path Lenovo_SetBiosSetting call SetBiosSetting(“SecurityChip,Active”)
表示“参数数量无效”。错误,但为什么?
Lenovo BIOS部署指南:http://download.lenovo.com/ibmdl/pub/pc/pccbbs/thinkcentre_pdf/hrdeploy_en.pdf
任何想法? 我不能使用VBS或PowerShell ......
谢谢,马丁
答案 0 :(得分:1)
在C#中尝试:
ManagementScope scope = new ManagementScope(@"\\.\root\wmi");
//
// Make change(s)
//
SelectQuery queryRead = new SelectQuery("SELECT * from Lenovo_SetBiosSetting");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, queryRead))
{
using (ManagementObjectCollection queryCollection = searcher.Get())
{
foreach (ManagementObject queryItem in queryCollection)
{
ManagementBaseObject inParams = queryItem.GetMethodParameters("SetBiosSetting");
inParams["parameter"] = "WakeOnLAN,Disable";
ManagementBaseObject outParams = queryItem.InvokeMethod("SetBiosSetting", inParams, null);
string result = outParams["return"] as string; // "Success"
}
}
}
//
// Commit to BIOS
//
queryRead = new SelectQuery("SELECT * from Lenovo_SaveBiosSettings");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, queryRead))
{
using (ManagementObjectCollection queryCollection = searcher.Get())
{
foreach (ManagementObject queryItem in queryCollection)
{
ManagementBaseObject inParams = queryItem.GetMethodParameters("SaveBiosSettings");
inParams["parameter"] = "";
ManagementBaseObject outParams = queryItem.InvokeMethod("SaveBiosSettings", inParams, null);
string result = outParams["return"] as string; // "Success"
}
}
}
PowerShell就是:
(gwmi -class Lenovo_SetBiosSetting -namespace root\wmi).SetBiosSetting("WakeOnLAN,Disable")
答案 1 :(得分:0)
我到达这篇文章试图找到一种方法来使用WMIC来获取Lenovo_BiosSetting
类中的所有对象。你的语法让我走上正轨。我不得不将你的WMIC查询更改为:
wmic /namespace:\\root\wmi path Lenovo_BiosSetting get
(注意双背斜杠)