我试图在Windows8.1Ind中设置一个自定义shell,并附带此版本的Windows附带的附加锁定功能。
我可以成功地在Lock Down中创建所需的条目,并通过c#和WMI打开和关闭自定义shell。
因为我们计划部署到很多设备上,所以我也想问题地应用自定义shell设置。
我使用WMI码发生器来帮助我访问和设置正确的值。
但是,WMI代码生成器和我的C#应用程序在试图运行生成器生成的代码时都会崩溃。
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()代码示例:
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吗?
发布于 2016-09-28 15:06:54
这是一个老问题,但我通过打开shell启动程序来解决这个问题,如这里所指定的:MSDN。它在“打开壳牌发射器”部分。
https://stackoverflow.com/questions/35345116
复制相似问题