如何获得在PowerShell中或C#进程的命令行信息 [英] How to get Command Line info for a process in PowerShell or C#
本文介绍了如何获得在PowerShell中或C#进程的命令行信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:如果我跑的notepad.exe C:\autoexec.bat
,
我怎样才能获得 C:?\autoexec.bat
在获取进程记事本
在PowerShell中
How can I get c:\autoexec.bat
in Get-Process notepad
in PowerShell?
或者我如何能得到 C:\autoexec.bat
在 Process.GetProcessesByName(记事本); ?code>在C#
Or how can I get c:\autoexec.bat
in Process.GetProcessesByName("notepad");
in C#?
推荐答案
在PowerShell中,您可以通过WMI获取进程的命令行:
In PowerShell you can get the command line of a process via WMI:
$process = "notepad.exe"
Get-WmiObject Win32_Process -Filter "name = '$process'" | select CommandLine
这篇关于如何获得在PowerShell中或C#进程的命令行信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文