问题描述
我目前正在使用业务自动化软件,这个想法是机器人模拟用户操作.有没有办法通过 powershell 访问任务管理器,因为机器人旨在操纵任务管理器,例如传入一个值以启动新任务、结束进程并查看 cpu 的性能等.我知道这可以使用 powershell 脚本或更好的 vb 脚本来实现.请问我如何做到这一点?
Am currently working with a business automation software, the idea is Robots simulate user actions. Is there a way to access the task manager through powershell as the robots are meant to manipulate the task manager e.g Pass in a value to start a new task, end a process and view the performance of the cpu etc . I know this can be achieved using powershell scripts or better still vb script. Please how do I achieve this?
为了记录,我使用的是带有 powershell 3.0 版的 Windows 7 机器.
For the records, I am using a windows 7 machine with powershell version 3.0.
推荐答案
尝试 get-process
获取正在运行的进程列表.
Try get-process
for a list of running processes.
即使用 get-process myprocess |stop-process
你可以停止 myprocess
.
With i.e. get-process myprocess |stop-process
you can stop myprocess
.
对于新进程,您可以 &
它们(& C:\Windows\System32\taskmgr.exe
)或使用 start-process
code>(检查 Get-help Start-Process
以获得帮助)cmdlet.您也可以为此使用 Invoke-WmiMethod
:
For new processes you can &
them ( & C:\Windows\System32\taskmgr.exe
) or use the start-process
(check Get-help Start-Process
for help ) cmdlet.You can also use Invoke-WmiMethod
for this :
Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList taskmgr.exe'
这篇关于使用 Powershell 从任务管理器中检索信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!