请考虑下面的代码(在.ps1 脚本中)
$latest = Get-ChildItem -Path $env:windows\security -Filter "my-app-here*.*" | Sort-Object -Descending | Select-Object -First 1
$file=$env:windows+"\security\"+$latest.name
start-process $file
这很好用。
如果我尝试将代码简化为:
$latest = Get-ChildItem -Path $env:windows\security -Filter "my-app-here*.*" | Sort-Object -Descending | Select-Object -First 1
start-process $env:windows+"\security\"+$latest.name
我收到错误信息:
start-process : This command cannot be run due to the error: The system cannot find the file specified.
你知道我可能做错了什么吗?非常感谢