Let's assume that there are no command-line arguments. How do you pass input data to a program?

I'm thinking you'd write the input to a file with a specific name, such that the program knows to open and read it as input. However, how would one discover the name of that file? Usually, running a command-line program without arguments or with some standard help argument (e.g. \?) produces some instruction on how to use it. But given an environment with no command-line arguments, how does one discover how to operate a program?

  • Not programmers related. Not sure this is even a stackoverflow question. Most probably a better fit for superuser.com – karlphillip Mar 19 '12 at 13:20
  • 2
    Stackoverflow FAQ said "Professional programmers interested in conceptual questions about software development, ask on Programmers.". Isn't this a conceptual question about software development? – Core Xii Mar 19 '12 at 13:24
  • 1
    @karlphillip - there's no code. It's a design question. – ChrisF Mar 19 '12 at 13:29
  • 1
    @karlphillip: It is certainly not a reverse engineering question. It's about operating system design, actually. – Core Xii Mar 19 '12 at 13:38
  • 1
    Do you need to understand how an existing program is doing this? Do you need to do something like that and you want to get some tips? – Adriano Repetti Mar 19 '12 at 13:42

You can use tools to display all the hardcoded strings inside the application, and hopefully the filename will show up.

Check OllyDBG on Windows and strings on Linux (it's a cmd-line application).

A more complex solution: fire up your favorite asm debugger (OllyDBG, GDB) and get your hands dirty.

  • Ah yes, one could read the program file and it could contain a standard header with this information. Though that somewhat postpones the issue - somehow you must then discover that standard. – Core Xii Mar 19 '12 at 13:27
  • 2
    The idea is to dump all the strings in the program. This can display a lot of interesting information, and one of those could be name of the file he is looking for. – karlphillip Mar 19 '12 at 13:29

In the .NET world, this is achieved with the use of an app.config file included with your source code. This is copied to the output folder with a name following the convention "MyApp.exe.config" where your application is "MyApp.exe".

I don't know if there are similar conventions for other languages.

  • A standardized, human-readable, self-documenting file describing the program's operation, supplied with it. Also known as a manual. Funny that didn't occur to me. – Core Xii Mar 19 '12 at 13:43
  • I'm not sure what you're saying. I've not described the manual in the answer. – RichardM Mar 19 '12 at 14:10
  • Well, that's the idea you gave me anyway. What I got from your answer was that there's some other, standardized file supplied with the program that hints to its operation one way or another. – Core Xii Mar 19 '12 at 14:22
  • The app.config file contains the application settings that are your inputs. Here's a link with more details and samples: generally.wordpress.com/2007/09/27/… – RichardM Mar 19 '12 at 14:45

Popular convention seems to be for programs to use standard streams for stuff like that:

In computer programming, standard streams are preconnected input and output channels between a computer program and its environment (typically a text terminal) when it begins execution...

You can see how it works using whatever command interpreter is available in your OS. In Windows, you may launch DOS shell and type help. In Unix you launch shell and type man.

  • Yes indeed. Though, without command-line arguments, there are no pipes, and as such, standard I/O would likely not be present as it'd be somewhat useless. – Core Xii Mar 19 '12 at 13:49
  • @CoreXii you may want to clarify your question pointing out that no standard I/O is expected to be used, either – gnat Mar 19 '12 at 13:54
  • It's not that it isn't expected. If it's the best solution, it's certainly valid. But given that pipes don't exist, I'd explore others first. – Core Xii Mar 19 '12 at 13:58
  • 1
    @Core Xii: Mistaken assumption. There is no reason to presume that pipes exist only in the presence of command lines. Win32 on Win95 is an obvious counter-example. It did have pipes, but not CMD.EXE (the 32 bits command line). – MSalters Mar 19 '12 at 15:01

You could look at COM, as implemented by Microsoft. In that system, the OS loads your DLL into memory when someone needs an object of your type. If anyone needs to pass information to that object, it can use the standard IUnknown::QueryInterface(GUID) method to obtain an well-known interface, and then pass information via that interface.

Of course, if your object doesn't have such an interface, it'd return E_NO_INTERFACE. But that's no different (just eassier to debug) than a CLI program ignoring its arguments.


Many Operating Systems already have the concept of "environment variables". This is a set of named values that are passed to every process, in addition to the command line arguments. Using C, you'd access them with getenv().

Similar to the /? convention for command lines, the OS writer can define a convention that the presence of a HELP variable in the environment means that a program should show usage information. In C code: if (getenv("HELP")) { ShowHelp(); }


I don't quite understand what the OP is really asking, but it is fairly common for command line programs to use environmental variables as inputs in lieu of command line parameters.

Of course that begs the question of where did the environmental variables come from.


You can create .bat file with your arguments in it.


I'm going for a straight-man answer.

You read the user's manual. Then you use some sort of input device like a keyboard or mouse to control the program. If the program requires a large amount of data, you can direct it to a file. Directing a program to a file has varied widely through the ages, but has standardized to OS typical popup windows.

If it's a command line program, with no command line arguments, then you are dependent on the program's interface. At some point you probably have to type in the path to the file name.

  • And how would you use such a program from another program? It must be usable without user intervention. – Core Xii Mar 19 '12 at 22:18
  • @CoreXii, That'd be a great detail to add to the question. – Philip Mar 20 '12 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.