从命令提示符中从正在运行的进程中获取命令行 [英] Obtain the command line from a running process from the Command Prompt

查看:137
本文介绍了从命令提示符中从正在运行的进程中获取命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想确定命令提示符(cmd.exe)上正在运行的进程的命令行参数.

I wanted to determine the command-line arguments of a running process at the Command Prompt (cmd.exe).

例如,如果我按以下方式启动abc.exe程序:

E.g., if I started my abc.exe program as follows:

abc -d 

我想稍后确定整个命令行. TASKLIST实用程序不提供此信息,因为它仅报告exe名称,而不报告启动进程所使用的参数.

I want to determine the whole command line later. The TASKLIST utility does not provide this info, because it just reports the exe name and not the arguments with which the process was started.

推荐答案

这是基于GUI的方法(在Windows 7-YMMV上测试).我不知道从命令行获取此数据的简便方法.

Here is a GUI-based method (Tested on Windows 7 - YMMV). I don't know of an easy method to get this data from the command-line.

  1. 打开任务管理器(CTRL + SHIFT + ESC),然后转到进程"选项卡.
  2. 从查看"菜单->选择列...
  3. 滚动到最底部,然后选择命令行"
  4. 在新显示的命令行"列中,您可以看到启动该过程的整个命令,包括任何命令行参数

命令行方法:

  1. 使用管理员权限启动PowerShell
  2. 使用Get-WmiObject列出进程并过滤上面的进程名称.通过下面的select语句添加/删除字段-示例:

  1. Start a PowerShell with administrator priviledges
  2. Use the Get-WmiObject to list processes and filter the process name above. Add/remove fields through the select statement below - example:

Get-WmiObject win32_process -Filter "name like '%notepad.exe'"|select CreationDate,ProcessId,CommandLine|ft -AutoSize

注意:本示例使用进程名称"notepad.exe",用您的特定方案替换该名称.

Note: The process name "notepad.exe" is used for this example, substitute the name for your specific scenario.

这篇关于从命令提示符中从正在运行的进程中获取命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆