简体   繁体   English

从调用进程获取命令行

[英]Get command line from calling process

We use a software which is capable of using scripts for different tasks. 我们使用能够使用脚本执行不同任务的软件。

In one script I want to start a little helper tool to input some additional data. 在一个脚本中,我想启动一个小帮助工具来输入一些额外的数据。 Therefore I need to know the command line parameters of the calling software shown in the picture below. 因此,我需要知道下图所示的调用软件的命令行参数。

TaskManager  - 命令行参数

Is there a possibility to get these from the calling process or at least to get them by looking for the "Image Name"? 是否有可能从调用过程中获取这些内容,或者至少通过查找“图像名称”来获取它们?

Combining the link from Wapac's comment with the Simon Mourier's answer in this question solved the problem. 结合Wapac评论中的链接和Simon Mourier在这个问题中的答案解决了这个问题。

Now I have two helper classes: 现在我有两个辅助类:

  1. CommandLineUtilities CommandLineUtilities
  2. ParentProcessUtilities ParentProcessUtilities

In my program I just need to call now: 在我的程序中,我只需要立即致电:

Process process = Process.GetCurrentProcess();
Process parent = ParentProcessUtilities.GetParentProcess(process.Id);
String[] parameters = CommandLineUtilities.getCommandLinesParsed(parent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM