0

WMIC (および C#) を使用して SetBiosSetting メソッドを呼び出す問題があります。

wmic /namespace:\root\wmi パス Lenovo_SetBiosSetting call SetBiosSetting "SecurityChip,Active"

wmic /namespace:\root\wmi パス Lenovo_SetBiosSetting 呼び出し SetBiosSetting SecurityChip,Active

wmic /namespace:\root\wmi パス Lenovo_SetBiosSetting call SetBiosSetting ("SecurityChip,Active")

「無効な数のパラメーター」が表示されます。エラーですが、なぜですか?

Lenovo 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

Lenovo_BiosSettingクラス内のすべてのオブジェクトを取得するために WMIC を使用する方法を見つけようとして、この投稿にたどり着きました。あなたの構文は私を正しい軌道に乗せました。WMIC クエリを次のように変更する必要がありました。

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

(ダブルバックスラッシュに注意してください)

于 2013-08-01T17:20:32.137 に答える