统一写入筛选器WMI AddExclusion

时间:2019-01-29 08:49:32

标签: c# vb.net wmi

我想将目录添加到我的UWF。 如何通过vb.net或C#做到这一点?

我在Mircrosoft上找到了这些链接。 https://docs.microsoft.com/en-us/windows-hardware/customize/enterprise/uwf-volumeaddexclusion

https://docs.microsoft.com/en-us/windows-hardware/customize/enterprise/uwf-registryfilteraddexclusion

我已经通过WMICodeCreator在下面尝试了此代码,但例如sInput="c:\Test"我收到异常错误消息Invalid ObjectPath。

Private Function UwfAddExclusion(sInput As String) As Boolean

    Try
        Dim classInstance As New ManagementObject("root\StandardCimv2\embedded", "UWF_Volume.ReplaceKeyPropery='ReplaceKeyPropertyValue'", Nothing)
        Dim inParams As ManagementBaseObject = classInstance.GetMethodParameters("AddExclusion")

        inParams("FileName") = sInput

        Dim outParams As ManagementBaseObject = classInstance.InvokeMethod("AddExclusion", inParams, Nothing)

        Console.WriteLine("Out parameters:")
        Console.WriteLine("ReturnValue: {0}", outParams("ReturnValue"))

        Return True
    Catch ex As Exception
        MsgBox("IsUwfAddExclusion: " + ex.Message)

        Return False
    End Try

    Return False
End Function

谢谢!

0 个答案:

没有答案