如何使用Powershell获取命令行参数

时间:2019-07-08 08:24:05

标签: windows powershell command-line-arguments

我正在开发Windows应用程序监视器,使用名称和命令行属性查找应用程序是否在Powershell中运行。但这行不通。

这是我在Powershell中启动dotnet应用程序的一段脚本

PS E:\work\myproject\netcore\BackgroundTasksSample-GenericHost\bin\Debug\netcoreapp2.1\publish> dotnet E:\work\myproject\netcore\BackgroundTasksSample-GenericHost\bin\Debug\netcoreapp2.1\publish\BackgroundTasksSample.dll
Application started. Press Ctrl+C to shut down.
Hosting environment: Production
Content root path: E:\work\myproject\netcore\BackgroundTasksSample-GenericHost\bin\Debug\netcoreapp2.1\publish\

这是我在Powershell中查询dotnet应用程序的一段脚本

Get-WmiObject Win32_Process  -Filter "name like '%dotnet%'" | Select Name, ProcessId, CommandLine

Name       ProcessId CommandLine
----       --------- -----------
dotnet.exe      7912

像任务管理器一样

Task Manager
Name         Command line 
dotnet.exe   dotnet E:\work\myproject\netcore\BackgroundTasksSample-GenericHost\bin\Debug\netcoreapp2.1\publish\BackgroundTasksSample.dll

我想要的结果是:

dotnet E:\work\myproject\netcore\BackgroundTasksSample-GenericHost\bin\Debug\netcoreapp2.1\publish\BackgroundTasksSample.dll

但是实际上它返回空。

0 个答案:

没有答案