Main example
List instances
# Abstract class: Get-CimInstance returns the instances of its subclasses
Get-CimInstance -ClassName Win32_ProcessStartup |
Select-Object -Property CreateFlags, ErrorMode, FillAttribute, PriorityClassAbstract class: it has no instances of its own. Get-CimInstance returns the instances of its subclasses.
Examples
Decode numeric values
# Lookup table for CreateFlags (values documented by Microsoft)
$createFlagsName = @{
1 = 'Debug_Process'
2 = 'Debug_Only_This_Process'
4 = 'Create_Suspended'
8 = 'Detached_Process'
16 = 'Create_New_Console'
512 = 'Create_New_Process_Group'
1024 = 'Create_Unicode_Environment'
16777216 = 'CREATE_BREAKAWAY_FROM_JOB'
67108864 = 'Create_Default_Error_Mode'
}
# Lookup table for ErrorMode (values documented by Microsoft)
$errorModeName = @{
2 = 'Fail_Critical_Errors'
4 = 'No_Alignment_Fault_Except'
8 = 'No_GP_Fault_Error_Box'
16 = 'No_Open_File_Error_Box'
}
Get-CimInstance -ClassName Win32_ProcessStartup |
Select-Object -Property @(
@{ Name = 'CreateFlags'; Expression = { $createFlagsName[[int]$_.CreateFlags] } }
@{ Name = 'ErrorMode'; Expression = { $errorModeName[[int]$_.ErrorMode] } }
'FillAttribute'
'PriorityClass'
)Query a remote computer (CIM session)
review before running# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
Get-CimInstance -CimSession $cimSession -ClassName Win32_ProcessStartup |
Select-Object -Property CreateFlags, ErrorMode, FillAttribute, PriorityClass
} finally {
Remove-CimSession -CimSession $cimSession
}WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.
Show the class structure
# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName Win32_ProcessStartup
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| CreateFlags# | uint32 | read/write | Additional values that control the priority class and the creation of the process. The following creation values can be specified in any combination, except as noted. Values (9)
CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| EnvironmentVariables# | string[] | read/write | List of settings for the configuration of a computer. Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains a block of environment settings for each user and one for the computer. The system environment block represents environment variables for all of the users of a specific computer. A user's environment block represents the environment variables that the system maintains for a specific user, and includes the set of system environment variables. By default, each process receives a copy of the environment block for its parent process. Typically, this is the environment block for the user who is logged on. A process can specify different environment blocks for its child processes. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| ErrorMode# | uint16 | read/write | On some non-x86 processors, misaligned memory references cause an alignment fault exception. The No_Alignment_Fault_Except flag lets you control whether or not an operating system automatically fixes such alignment faults, or makes them visible to an application. On a millions of instructions per second (MIPS) platform, an application must explicitly call SetErrorMode with the No_Alignment_Fault_Except flag to have the operating system automatically fix alignment faults. How an operating system processes several types of serious errors. You can specify that the operating system process errors, or an application can receive and process errors. The default setting is for the operating system to make alignment faults visible to an application. Because the x86 platform does not make alignment faults visible to an application, the No_Alignment_Fault_Except flag does not make the operating system raise an alignment fault error—even if the flag is not set. The default state for SetErrorMode is to set all of the flags to 0 (zero). (1) Default Values (4)
CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| FillAttribute# | uint32 | read/write | The text and background colors if a new console window is created in a console application. These values are ignored in graphical user interface (GUI) applications. To specify both foreground and background colors, add the values together. For example, to have red type (4) on a blue background (16), set the FillAttribute to 20. 1 Foreground_Blue 2 Foreground_Green 4 Foreground_Red 8 Foreground_Intensity 16 Background_Blue 32 Background_Green 64 Background_Red 128 Background_Intensity CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| PriorityClass# | uint32 | read/write | Priority class of the new process. Use this property to determine the schedule priorities of the threads in the process. If the property is left null, the priority class defaults to Normal—unless the priority class of the creating process is Idle or Below_Normal. In these cases, the child process receives the default priority class of the calling process. Values (6)
CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| ShowWindow# | uint16 | read/write | How the window is displayed to the user. It can be any of the values that can be specified in the *nCmdShow* parameter for the ShowWindow function. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| Title# | string | read/write | Text displayed in the title bar when a new console window is created; used for console processes. If NULL, the name of the executable file is used as the window title. This property must be NULL for GUI or console processes that do not create a new console window. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| WinstationDesktop# | string | read/write | The name of the desktop or the name of both the desktop and window station for the process. A backslash in the string indicates that the string includes both desktop and window station names. If WinstationDesktop is NULL, the new process inherits the desktop and window station of its parent process. If WinstationDesktop is an empty string, the process does not inherit the desktop and window station of its parent process. The system determines if a new desktop and window station must be created. A window station is a secure object that contains a clipboard, a set of global atoms, and a group of desktop objects. The interactive window station that is assigned to the logon session of the interactive user also contains the keyboard, mouse, and display device. A desktop is a secure object contained within a window station. A desktop has a logical display surface and contains windows, menus, and hooks. A window station can have multiple desktops. Only the desktops of the interactive window station can be visible and receive user input. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| X# | uint32 | read/write | The X offset of the upper left corner of a window if a new window is created—in pixels. The offsets are from the upper left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the *X* parameter of CreateWindow is CW_USEDEFAULT. [!Note X] and Y cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| XCountChars# | uint32 | read/write | Screen buffer width in character columns. This property is used for processes that create a console window, and is ignored in GUI processes. Note: XCountChars and YCountChars cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| XSize# | uint32 | read/write | Pixel width of a window if a new window is created. For GUI processes, this is only used the first time the new process calls CreateWindow to create an overlapped window if the nWidth parameter of CreateWindow is CW_USEDEFAULT. Note: XSize and YSize cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| Y# | uint32 | read/write | Pixel offset of the upper-left corner of a window if a new window is created. The offsets are from the upper-left corner of the screen. For GUI processes, the specified position is used the first time the new process calls CreateWindow to create an overlapped window if the *y* parameter of CreateWindow is CW_USEDEFAULT. [!Note X] and Y cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| YCountChars# | uint32 | read/write | Screen buffer height in character rows. This property is used for processes that create a console window, but is ignored in GUI processes. Note: XCountChars and YCountChars cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. | ||||||||||||||||||||||||||||||
| YSize# | uint32 | read/write | Pixel height of a window if a new window is created. For GUI processes, this is used only the first time the new process calls CreateWindow to create an overlapped window if the *nWidth* parameter of CreateWindow is CW_USEDEFAULT. Note: XSize and YSize cannot be specified independently. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. |
Remarks
This class is derived from Win32_MethodParameterClass.
Overview
The Win32_Process Create method enables you to configure startup options for any new process running on a computer. For example, you can configure a process so that it starts in a "hidden" window, which prevents a user from seeing, and possibly interrupting, it. If the process runs in a command window, you can configure the size, title, and foreground and background colors of the window.
Startup options are configured using the Win32_ProcessStartup class. Win32_ProcessStartup is a Method Type class; the Method Type class exists solely to pass information to a method. In this case, all the properties of an instance of Win32_ProcessStartup are passed to an instance of Win32_Process.
Using Win32_ProcessStartup
1. Create an instance of Win32_ProcessStartup.
2. Configure the properties of the new instance.
3. Include the instance as part of the Win32_Process Create method.
For example, if you have created a Win32_ProcessStartup instance named objConfig, you would pass the object name in the Create method as follows:
errReturn = objProcess.Create("Database.exe", null, objConfig, intProcessID)
Inheritance
Superclass chain
- Win32_MethodParameterClass
- Win32_ProcessStartup
Known subclasses
No known subclass.
Requirements
- Namespace
- root/cimv2
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- MOF file
- CIMWin32.mof
- DLL
- CIMWin32.dll
Class qualifiers
Abstract UUID("{8502C4DB-5FBB-11D2-AAC1-006008C78BC7}") AMENDMENT
Microsoft source
Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.