Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 如何使用Powershell暂停另一个进程_Windows_Powershell - Fatal编程技术网

Windows 如何使用Powershell暂停另一个进程

Windows 如何使用Powershell暂停另一个进程,windows,powershell,Windows,Powershell,我有一个进程,我想暂停执行一段时间。 我过去的做法是右键单击,然后在taskmanager的详细信息选项卡中选择“暂停流程”,但这是我现在希望避免的重复劳动 通过一些搜索,我发现了一些关于“”的Microsoft文档,它们是“PsTools”工具包的一部分。虽然它可以做我想做的事情,但我不喜欢我的脚本依赖于一些没有嵌入脚本中的工具 这是我当前工作原型的一个示例: $ProcessName = "notepad"; cd "C:\Users\username\too

我有一个进程,我想暂停执行一段时间。 我过去的做法是右键单击,然后在taskmanager的详细信息选项卡中选择“暂停流程”,但这是我现在希望避免的重复劳动

通过一些搜索,我发现了一些关于“”的Microsoft文档,它们是“PsTools”工具包的一部分。虽然它可以做我想做的事情,但我不喜欢我的脚本依赖于一些没有嵌入脚本中的工具

这是我当前工作原型的一个示例:

$ProcessName = "notepad";

cd "C:\Users\username\tools\PSTools";
.\pssuspend.exe -nobanner $ProcessName
Start-Sleep -Seconds 9;
.\pssuspend.exe -nobanner -r $ProcessName
# Note: the -nobanner makes a banner not appear for cleaner console output
# Note2: the -r is for resume
我想知道的是,是否有其他方法可以实现这一点。 否则,如何在PowerShell脚本中嵌入
pssupend.exe

示例是C#。您将把它移植到PowerShell。您将需要导入Windows API来完成此操作,如示例中所示。