0

我有一个使用 WMIC(以及 C#)调用 SetBiosSetting 方法的问题

wmic /namespace:\root\wmi 路径 Lenovo_SetBiosSetting 调用 SetBiosSetting "SecurityChip,Active"

wmic /namespace:\root\wmi 路径 Lenovo_SetBiosSetting 调用 SetBiosSetting SecurityChip,Active

wmic /namespace:\root\wmi 路径 Lenovo_SetBiosSetting 调用 SetBiosSetting ("SecurityChip,Active")

给出“无效的参数数量”。错误,但为什么?

联想 BIOS 部署指南:http: //download.lenovo.com/ibmdl/pub/pc/pccbbs/thinkcentre_pdf/hrdeploy_en.pdf

任何的想法 ?我不能使用 VBS 或 PowerShell ...

谢谢,马丁

4

2 回答 2

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")
于 2012-12-10T22:45:07.007 回答
0

我来到这篇文章试图找到一种使用 WMIC 获取Lenovo_BiosSetting类中所有对象的方法。你的语法让我走上了正确的轨道。我不得不将您的 WMIC 查询更改为:

wmic /namespace:\\root\wmi path Lenovo_BiosSetting get

(注意双反斜杠)

于 2013-08-01T17:20:32.137 回答