WMI Tasks: Processes
WMI tasks for processes obtain information such as the account under which a process is running. You can perform actions like creating processes. For other examples, see the TechNet ScriptCenter at http://www.microsoft.com/technet.
The script examples shown in this topic obtain data only from the local computer. For more information about how to use the script to obtain data from remote computers, see Connecting to WMI on a Remote Computer.
The following procedure describes how to run a script.
To run a script
- Copy the code and save it in a file with a .vbs extension, such as filename.vbs. Ensure that your text editor does not add a .txt extension to the file.
- Open a command prompt window and navigate to the directory where you saved the file.
- Type cscript filename.vbs at the command prompt.
- If you cannot access an event log, check to see if you are running from an Elevated command prompt. Some Event Log, such as the Security Event Log, may be protected by User Access Controls (UAC).
The following table lists script examples that can be used to obtain various types of data from the local computer.
| How do I... | WMI classes or methods |
|---|---|
| ...run an application in a hidden window? |
Call the application from a script that uses the Win32_Process and Win32_ProcessStartup classes.
No code example is currently available or this language may not be supported.
|
| ...determine which scripts are running on the local computer? |
Use the Win32_Process class and return all processes with the name Cscript.exe or Wscript.exe. To determine the individual scripts running in these processes, check the value of the CommandLine property.
No code example is currently available or this language may not be supported.
|
| ...find out the account name under which a process is running? |
Use the Win32_Process class and the GetOwner method.
No code example is currently available or this language may not be supported.
|
| ...change the priority of a running process? |
Use the Win32_Process class and the SetPriority method.
No code example is currently available or this language may not be supported.
|
| ...terminate a process using a script? |
Use the Win32_Process class and the Terminate method.
No code example is currently available or this language may not be supported.
|
| ...determine how much processor time and memory each process is using? |
Use the Win32_Process class and properties such as KernelModeTime, WorkingSetSize, PageFileUsage, and PageFaults.
No code example is currently available or this language may not be supported.
|
| ...tell what applications are running on a remote computer? |
Use the Win32_Process class.
No code example is currently available or this language may not be supported.
|
Related topics