0

What command would I use in CMD to get all of a program's available switches/arguments? For example, program abc.exe might have a switch of /o that starts the program in offline mode. Assuming I did not know about the /o switch, what would I need to do in Command Prompt to get this information?

Edit:

I would like to also add that I know how I can find the switches and arguments that are already being used in a running program - this is not what I am after. I want to obtain ALL available command line arguments for a program, whether it's running or not.

3 Answers3

2

Except for already mentioned /?, --help, reading documentation and googling there is no standard way to do it. Unfortunately, some programs don't document their switches well - there is (almost) nothing that can be done with those.

This is why: each program analyzes its command line completely differently, and even having switches is just an agreement that most authors tend to follow: some have /dos style switches, some are -uNIX style, some use --gnu-long-style=switches, and some just don't understand any, taking the first thing they see as a file name.

So, parameter analyzis is a part of program code, and so to know what parameters the program actually accepts you would need to read its source code, which you normally do not even have.

The only other option is to disassemble the program in question. Disassembly is basicly taking a program apart, instruction by instruction, trying to figure what it tries to do and how. It takes a lot of time and is quite a hard to learn.

Sometimes you can get away with opening your program in a hex editor and searching for a command you know, often somewhere near the end, and then trying anything nearby that looks like a switch.

Jack White
  • 1,039
  • 7
  • 7
0

Most programs will accept the /? or -? switch to allow you to see what parameters the command will accept. Some GNU or *nix-based utilities (in layman's terms, a program mostly intended for Linux users, but also available for other platforms) require you to add --help for it to give you brief documentation.

When all fails, of course, you can just use documentation.

To find the switches used for a running program, you can use Process Explorer or Process Hacker, or even the command line as explained in a related question.

oldmud0
  • 4,312
  • 3
  • 26
  • 45
0

Microsoft actually has made a very helpful tool that covers the build-in commands in a few shells (bash, zsh, fish, pwsh, powershell - but not "cmd" or the confusing, almost-the-same-but-surely-it-must-be-different "Windows Terminal").

It does not work for programs in general, as programs are quite free to invent whatever syntax they like for command-line arguments (something Microsoft apparently forgot when giving us %0, %1 and so on, but no way to get the full string, unparsed, making it nigh-on impossible to pass arguments correctly in scripts; this is in fact the problem I'm having at the moment and the reason I stumbled across this page).

MS clearly had developers (and only a subset of us) in mind when designing this thing, because they made it as a node package. If you want to try it you can get node from nodejs.org, install it, then run 'npm install -g @microsoft/inshellisense', then 'inshellisense bind'. Then you're set up, but you still need to press CTRL+a the next time you're in a shell in order to activate it (the above bind command sets up this keyboard shortcut).

It's super useful for the shells that it does supports (and some programs not part of a stanard installation, but very commonly used by devs, such as git), see the animation/demo at the above github page, but I wish they had supported "cmd" as I find PowerShell to be so aeasthetically displeasing I refuse to use it for anything that can be done without it... the incredibly clunky, verbose syntax and endless typing for the tiniest of things is not for me.