ppi*_*rek 1 powershell start-process
这应该在 3 岁以上的 PowerShell 中正常工作。我需要运行两个进程:wuapp.exe 和带有 ScreenSaver 选项卡的 desk.cpl。我遇到的问题是,一旦我启动 wuapp.exe,进程名称就会在任务管理器中显示为 explorer.exe - 当前代码适用于 wuapp.exe,但不适用于每台机器。另一件事是当我杀死 rundll32 时,其他应用程序也会关闭。你有什么建议?
$wshell = New-Object -ComObject Wscript.Shell
Start-Process wuapp.exe
(New-Object -comObject Shell.Application).Windows() | foreach-object {$_.quit()}
Start-Process rundll32 desk.cpl,InstallScreenSaver
Stop-Process -ProcessName rundll32* -Force
Run Code Online (Sandbox Code Playgroud)
我不完全确定您wuapp.exe显示为是什么意思explorer.exe,但跟踪该rundll32过程相当简单。
使用Start-Process与PassThru参数使其返回其创建的过程:
$ScreenSaverCpl = Start-Process rundll32 desk.cpl,InstallScreenSaver -PassThru
# Call Stop-Process when no longer needed:
Stop-Process $ScreenSaverCpl
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8123 次 |
| 最近记录: |