Process Class

MSBuild Extension Pack

Process Class MSBuild Extension Pack Help 4.0.12.0
Valid TaskActions are:

CheckRunning (Required: ProcessName Output: IsRunning)

Create (Required: Parameters Output: ReturnValue, ProcessId)

Get (Required: ProcessName, Value Optional: User, ProcessName, IncludeUserInfo Output: Processes)

Terminate (Required: ProcessName or ProcessId)

Remote Execution Support: Yes

Inheritance Hierarchy

SystemObject  Microsoft.Build.UtilitiesTask
    MSBuild.ExtensionPackBaseTask
      MSBuild.ExtensionPack.ComputerProcess

Namespace: MSBuild.ExtensionPack.Computer
Assembly: MSBuild.ExtensionPack (in MSBuild.ExtensionPack.dll) Version: 4.0.0.0

The Process type exposes the following members.

Constructors

  NameDescription
Public methodProcess
Top
Properties

  NameDescription
Public propertyIncludeUserInfo
Sets whether to include user information for processes. Including this will slow the query. Default is false;
Public propertyIsRunning
Gets whether the process is running
Public propertyParameters
Sets the Parameters for Create. Use #~# separate name and value.
Public propertyProcesses
Gets the list of processes. The process name is used as the identity and the following metadata is set: Caption, Description, Handle, HandleCount, KernelModeTime, PageFaults, PageFileUsage, ParentProcessId, PeakPageFileUsage, PeakVirtualSize, PeakWorkingSetSize, Priority, PrivatePageCount, ProcessId, QuotaNonPagedPoolUsage, QuotaPagedPoolUsage, QuotaPeakNonPagedPoolUsage, QuotaPeakPagedPoolUsage, ReadOperationCount, ReadTransferCount, SessionId, ThreadCount, UserModeTime, VirtualSize, WindowsVersion, WorkingSetSize, WriteOperationCount, WriteTransferCount
Public propertyProcessId
Gets or Sets the ProcessId
Public propertyProcessName
Sets the regular expression to use for filtering processes. Default is .*
Public propertyReturnValue
Gets the ReturnValue for Create
Public propertyUser
Sets the regular expression to use for filtering processes. Default is .*
Top
Examples

<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <TPath>$(MSBuildProjectDirectory)\..\MSBuild.ExtensionPack.tasks</TPath>
        <TPath Condition="Exists('$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks')">$(MSBuildProjectDirectory)\..\..\Common\MSBuild.ExtensionPack.tasks</TPath>
    </PropertyGroup>
    <Import Project="$(TPath)"/>
    <ItemGroup>
        <WmiExec3 Include="CommandLine#~#notepad.exe"/>
    </ItemGroup>
    <Target Name="Default">
        <MSBuild.ExtensionPack.Computer.Process TaskAction="Terminate" ProcessId="9564"/>
        <MSBuild.ExtensionPack.Computer.Process TaskAction="Create" Parameters="@(WmiExec3)">
            <Output TaskParameter="ReturnValue" PropertyName="Rval2"/>
            <Output TaskParameter="ProcessId" PropertyName="PID"/>
        </MSBuild.ExtensionPack.Computer.Process>
        <Message Text="ReturnValue: $(Rval2). ProcessId: $(PID)"/>
        <MSBuild.ExtensionPack.Computer.Process TaskAction="CheckRunning" ProcessName="notepad.exe">
            <Output PropertyName="Running" TaskParameter="IsRunning"/>
        </MSBuild.ExtensionPack.Computer.Process>
        <Message Text="notepad.exe IsRunning: $(Running)"/>
        <MSBuild.ExtensionPack.Computer.Process TaskAction="Terminate" ProcessName="notepad.exe"/>
        <MSBuild.ExtensionPack.Computer.Process TaskAction="CheckRunning" ProcessName="notepad.exe">
            <Output PropertyName="Running" TaskParameter="IsRunning"/>
        </MSBuild.ExtensionPack.Computer.Process>
        <Message Text="notepad.exe IsRunning: $(Running)"/>
        <MSBuild.ExtensionPack.Computer.Process TaskAction="Get" IncludeUserInfo="true">
            <Output ItemName="ProcessList" TaskParameter="Processes"/>
        </MSBuild.ExtensionPack.Computer.Process>
        <Message Text="%(ProcessList.Identity)  - %(ProcessList.User) - %(ProcessList.OwnerSID)"/>
    </Target>
</Project>
See Also

Reference