Knowing an exe file arguments

  • Thread starter Thread starter dushkin
  • Start date Start date
D

dushkin

Hi,

Is there a way to know an exe file arguments?
Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?

Thanks.
 
Is there a way to know an exe file arguments?
Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?

No, command line arguments are just a string and are parsed by the program.
Therefore you'd have to disassemble the code to figure out what it's doing.
Of course you might be able to search the file for strings, but it probably
won't tell you much.
 
Hi,

 Is there a way to know an exe file arguments?
 Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?

Thanks.

The answer is, yes, kind of. Look at the WMI stuff, you can use
something like this, if you know the process name:

string wmiQuery = string.Format("select CommandLine from Win32_Process
where Name='{0}'", processName);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection retObjectCollection = searcher.Get();
foreach (ManagementObject retObject in retObjectCollection)
Console.WriteLine("[{0}]", retObject["CommandLine"]);
 
Is there a way to know an exe file arguments?
Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?

If it is a console app that is written with user friendliness
in mind, then one of:

programname
programname -?
programname -h
programname /?
programname /h

should give some info.

Arne
 
Is there a way to know an exe file arguments?
Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?

The answer is, yes, kind of. Look at the WMI stuff, you can use
something like this, if you know the process name:

string wmiQuery = string.Format("select CommandLine from Win32_Process
where Name='{0}'", processName);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection retObjectCollection = searcher.Get();
foreach (ManagementObject retObject in retObjectCollection)
Console.WriteLine("[{0}]", retObject["CommandLine"]);

That is for a running program.

Arne
 
The answer is, yes, kind of. Look at the WMI stuff, you can use
something like this, if you know the process name:
string wmiQuery = string.Format("select CommandLine from Win32_Process
where Name='{0}'", processName);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection retObjectCollection = searcher.Get();
foreach (ManagementObject retObject in retObjectCollection)
     Console.WriteLine("[{0}]", retObject["CommandLine"]);

That is for a running program.

Arne

Yes, that's how I read his question. If he meant what to run it WITH,
obviously,
there is no way. Unless he's talking about shortcut links.

Matt
 
Is there a way to know an exe file arguments?
Meaning: if an exe file can or should be executed with some
arguments, can I programmaticaly get them?
The answer is, yes, kind of. Look at the WMI stuff, you can use
something like this, if you know the process name:
string wmiQuery = string.Format("select CommandLine from Win32_Process
where Name='{0}'", processName);
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(wmiQuery);
ManagementObjectCollection retObjectCollection = searcher.Get();
foreach (ManagementObject retObject in retObjectCollection)
Console.WriteLine("[{0}]", retObject["CommandLine"]);

That is for a running program.

Yes, that's how I read his question. If he meant what to run it WITH,
obviously,
there is no way. Unless he's talking about shortcut links.

The "or should be" gives me the impression that
it is potential arguments.

But I could be wrong.

Arne
 
Thank you guys all for your comments.

1. Yes, the arguments are not mandatory. They are potential.
2. I hoped I could know the exe arguments BEFORE I run it, bacause I
wanted to avoid the need to be familiar with the arguments list before
running the exe and let the end user select an exe and automatically
display him the arguments list. But I understand now that it is
probably impossible...
 
Back
Top