start -process -passThru无法抓住流程ID吗?
我有一个PowerShell脚本,可以通过start -Process $ type -passthru
通过返回的PID打开和关闭.txt
.exe .exe 。但是,如果我尝试使用.png
s做同样的事情,我会得到此错误:
start-process:由于系统无法找到所需的所有信息,因此无法完全运行此命令。
我正在尝试获得返回的PID,以便我可以关闭默认的照片编辑器,而无需按名称明确调用。代码样本:
$object = Get-ChildItem | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-730)} | Select-Object -Property Name
[System.Collections.ArrayList] $filearray = $object
$removed = $filearray[-1].Name
$open_photo = Start-Process -FilePath $removed -passthru
$open_photo.Id
I have a PowerShell script able to open and close .txt
and .exe
via a returned PID from Start-process $type -Passthru
. However, if I try to do this same thing with .png
s I get this error:
Start-Process : This command cannot be run completely because the system cannot find all the information required.
I am trying to get a returned PID so I can close the default photo editor without having to explicitly call it by name. Code sample:
$object = Get-ChildItem | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-730)} | Select-Object -Property Name
[System.Collections.ArrayList] $filearray = $object
$removed = $filearray[-1].Name
$open_photo = Start-Process -FilePath $removed -passthru
$open_photo.Id
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论