简体   繁体   中英

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.

Now I have two helper classes:

  1. CommandLineUtilities
  2. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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