Reputation: 831
Is there anyway for me to get the list of available command line arguments for an exe? I need to create a Powershell script that start the Relius Agent Manager program, but this program requires database login and password info to load.
I can obtain the login/pass info, but I need to know the names of the argument I'll need to pass them through.
It doesn't matter if I use Powershell or C# to retrieve the list of arguments, I just need to know their darn names.
I read up on the Process class in C# but I don't see anything that will actually list the available arguments, only how to list what was passed when a process was started.
Upvotes: 3
Views: 31669
Reputation: 831
Thanks for all of your help. I was able to solve it by having someone start it manually and then log in, and then I checked this list of all running processes with this command:
"WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid"
I was then able to find exactly what was passed when it was run from the file that command generated and execute that command in PowerShell using something like:
$exp = "&'C:\path\to\the\exe.exe' /param1 /param2 /param3" invoke-expression $exp
Upvotes: 2
Reputation: 531
search for universal silent switch finder. it is actually possible to do programmatically but requires deep diving into binary executable. if interested check http://code.google.com/p/pefile/wiki/PEiDSignatures
Upvotes: 1
Reputation: 12496
There is no way to query the supported command line arguments. Try running the program from a command prompt with no arguments, with an invalid argument, with /h, /?, -h, --help and similar arguments to see if one of these prompts the program to output a list of allowed arguments.
Upvotes: 6