Applies to: desktop apps only
The GetOwner WMI class method retrieves the user name and domain name under which the process is running.
This topic uses Managed Object Format (MOF) syntax. For more information about using this method, see Calling a Method.
Syntax
uint32 GetOwner( [out] string User, [out] string Domain );
Parameters
- User [out]
-
Returns the user name of the owner of this process.
- Domain [out]
-
Returns the domain name under which this process is running.
Return value
| Return code | Description |
|---|---|
|
Successful Completion |
|
Access Denied |
|
Insufficient Privilege |
|
Unknown Failure |
|
Path Not Found |
|
Invalid Parameter |
Examples
For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.
For C++ code examples, see WMI C++ Application Examples.
The following VBScript code example obtains the owner for each running process.
strComputer = "." Set colProcesses = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate}!\\" & strComputer & _ "\root\cimv2").ExecQuery("Select * from Win32_Process") For Each objProcess in colProcesses Return = objProcess.GetOwner(strNameOfUser) If Return <> 0 Then Wscript.Echo "Could not get owner info for process " & _ objProcess.Name & VBNewLine _ & "Error = " & Return Else Wscript.Echo "Process " _ & objProcess.Name & " is owned by " _ & "\" & strNameOfUser & "." End If Next
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Namespace |
\root\CIMV2 |
|
MOF |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 3/9/2012
