首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过WMI设置自定义外壳

通过WMI设置自定义外壳
EN

Stack Overflow用户
提问于 2016-02-11 16:43:41
回答 1查看 860关注 0票数 0

我试图在Windows8.1Ind中设置一个自定义shell,并附带此版本的Windows附带的附加锁定功能。

我可以成功地在Lock Down中创建所需的条目,并通过c#和WMI打开和关闭自定义shell。

因为我们计划部署到很多设备上,所以我也想问题地应用自定义shell设置。

我使用WMI码发生器来帮助我访问和设置正确的值。

但是,WMI代码生成器和我的C#应用程序在试图运行生成器生成的代码时都会崩溃。

代码语言:javascript
复制
Unhandled Exception: System.ArgumentOutOfRangeException: Specified argument was
out of the range of valid values.
Parameter name: path
   at System.Management.ManagementObject.ManagementObjectCTOR(ManagementScope sc
ope, ManagementPath path, ObjectGetOptions options)
   at WMISample.CallWMIMethod.Main()

代码示例:

代码语言:javascript
复制
public static void Main()
        {
            try
            {
                ManagementObject classInstance = 
                    new ManagementObject("root\\StandardCimv2\\embedded", 
                    "WESL_UserSetting", null);

                // Obtain in-parameters for the method
                ManagementBaseObject inParams = 
                    classInstance.GetMethodParameters("SetCustomShell");

                // Add the input parameters.
                inParams["DefaultAction"] =  3;
                inParams["Shell"] =  "C:\\Dash\\someapp.exe";
                inParams["Sid"] =  "S-1-5-21-2560287794-1129801719-3036876794-1001";

                // Execute the method and obtain the return values.
                ManagementBaseObject outParams = 
                    classInstance.InvokeMethod("SetCustomShell", inParams, null);

                // List outParams
                Console.WriteLine("Out parameters:");
                Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
            }
            catch(ManagementException err)
            {
                MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
            }
        }

文档中没有提到任何路径。有人能建议为什么代码没有设置自定义的shell吗?

EN

回答 1

Stack Overflow用户

发布于 2016-09-28 15:06:54

这是一个老问题,但我通过打开shell启动程序来解决这个问题,如这里所指定的:MSDN。它在“打开壳牌发射器”部分。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35345116

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档