C# WinRM Session Invoke with WMI class as parameter

32 views Asked by At

I'm trying to invoke the Win32_Process Create Method over WinRM without showing a Window. This can be done by passing in Win32_ProcessStartup with the ProcessStartupInformation parameter. But I can't figure out how to specify if over WinRM.

The following parameter XML works for just launching the process:

<p:Create_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/ROOT/cimv2/Win32_Process">
    <p:CommandLine>CMD.EXE</p:CommandLine>
</p:Create_INPUT>

Then I tried adding the ProcessStartupInformation multiple ways

<!-- Attempt 1 -->
<p:Create_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/ROOT/cimv2/Win32_Process">
    <p:CommandLine>CMD.EXE</p:CommandLine>
    <p:ProcessStartupInformation>
        <a:ShowWindow xmlns:a="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_ProcessStartup" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common">
            <cim:uint16>0</cim:uint16>
        </a:ShowWindow>
    </p:ProcessStartupInformation>
</p:Create_INPUT>
<!-- Attempt 2 -->
<p:Create_INPUT xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/ROOT/cimv2/Win32_Process">
    <p:CommandLine>CMD.EXE</p:CommandLine>
    <p:ProcessStartupInformation>
        <a:Win32_ProcessStartup xmlns:a="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_ProcessStartup">
            <a:ShowWindow>0</a:ShowWindow>
        </a:Win32_ProcessStartup>
    </p:ProcessStartupInformation>
</p:Create_INPUT>

Sadly all of those end in: System.Runtime.InteropServices.COMException (0x80338041): The SOAP XML in the message does not match the corresponding XML schema definition. Change the XML and retry.

Since it works without the ProcessStartupInformation parameter the error is definitly there. But I can't find any documentation on how to specify a nested WMI class.

0

There are 0 answers