Running Program Through Command Prompt

Hi guys,

I did a bit of a google search but I am still having issues with this. How do I run a program from the command prompt? It is a requirement for my class that I run the program from the command prompt and read variables from the command prompt. I have no issues with the coding but I have no idea how to run something from the command prompt. Does anyone have an easy way to do this or a to the point explanation of how to do it?

Thanks in advance
Let's first open the command prompt.
1. Hold that "Window" or "Start" key on your keyboard and then press "R". This brings up the "Run" command.
2. Now type "cmd". Voila, we have a command prompt.

Now you have to know the location of your excecutable. Let's say it's in c:\temp\.
3. Browse to the directory of your excecutible with the "cd" command. Example:
1
2
  C:\Users\Stewbond> cd c:\temp\
  C:\temp> 

4. Now type the name of the program:
C:\temp> MyProgram.exe
note: if the program requires arguments, you can enter them here and use the "start command". For example:
C:\temp> start MyProgram.exe configuration.cfg

Voila!
Last edited on
If you don't know where your .exe file is, go to where you saved you folder and look in sub-directories called either debug/release/stage it will most likely be there. If you can only find one in debug you should try and find out how to build a release version of your software (unless your purposely using debug and you know what your doing, in which case ignore everything I just said)

Also when using the command prompt it's probably worth know that pressing tab will complete whatever you were type press it several times to go through the different options, can be done without having typed anything it at all. Press up to show the last command entered. and you don't have to type out the complete path name, type cd whatever to go into directory whatever from where you were, cd .. to go up one level. There's more, but that's the basics.

@Stewbond: What does the start command do? I've read in arguments from the command line before using argv[] but I've never had to type start.
So my issue is in TheMeerkats first paragraph. I can only find the codes exe file in debug but it looks a little weird (ie. it's not simple program.exe, it's program.exe.embed.manifest). So how do I build a released version? Also can I just save the program in a file somewhere else or do I need to (somehow?) save the program.exe somewhere else in order to access it?

I understand directories and such and I also understand how to use the command prompt, I just have no idea how to actually make my written programs run from the command prompt...
Are you using visual studio? I had been using visual studio a few months ago when I cam across the exact same problem. If it is visual studio (and this might also apply to some other IDEs) on the bar at the top of the screen, the same one where the save/open icons are, it will say debug (or something similar) and hit the drop down arrow, and select release. Then rebuild it and in the release folder within your project folder you should find a .exe file. Good luck.
So I tried doing it with release set but when looking through the release folder their is nothing that is simple Program.exe. What am I missing here? For some reason I cannot find anywhere, something that simply is the executable file for the program...
Last edited on
This is infuriating...
Are you allowed to compile it in the command line as well or are you forced to compile in the IDE itself?
closed account (1vRz3TCk)
Where the output of the compiler is placed will depend on how the Solution and projects are setup.

If you go for default settings in your project you may find the output in a folder (debug or release) in the solution directory.
Sometimes there is two release folders as well. Within your project folder, you will have a debug folder a release folder and another folder with the same name as your project. Then within that folder you will have a debug and release folder. If you have them, check both debug and both release folders.
So I am going to bring this back up because I still have not figured out how to actually compile a program using the command prompt. I am still having the issue where I cannot find my .exe file. I can only find a file that seems close, it is, program_name.exe.embed.manifest .... Is this the file I want to run in the command prompt?
Well I can't be sure about your current set up. But for me, in this folder
My Documents\Visual Studio 2008\Projects\test\test\Debug
I have a file called test.exe.embed.manifest

and in this folder
My Documents\Visual Studio 2008\Projects\test\Release
I have a file called test.exe

Hopefully for you it will be something similar. Note though that these files were not created at the same time. Make sure that you have changed it to do a release compile, and try doing a clean solution followed by a rebuild solution, both from the build menu. If your not using visual studio the names of these might be slightly different but it should be reasonably obvious what I mean (hopefully).
I had libraries linked to my program that seem to have been removed when I changed it to release so now I cannot compile because I have an error and can't figure out how to reconnect the libraries. This shit is killing me...
Sorry man I really wouldn't know how to help you when it comes to linking libraries and things like that. If you set it back the way it had been before, and see if it still works? Or does it seem to just be completely ruined?
I am not that worried about ruining the links because I know how to set those back and its only 2 libraries so it doesn't take long. I just cant run the release because I do not know how to link to a release version and on top of that I have some other programs that I want to run using the command prompt that don't have linked libraries and when I run that I still don't get a .exe. I think I am just doomed to never be able to do this. I'll keep at it, thanks for your help.
Well good luck. I really wish I could help more, I remember when I was first trying to run my program from the command line I was having all sorts of problems probably quite similar to yourself and I had done the things I said, and played about with some settings, and it was driving me crazy for ages, then it all just worked. Don't even really know what I did differently, but it worked and I didn't question it and I don't at all remember what I did. As I said though, good luck, and let us know what the problem was when you fix it.
Topic archived. No new replies allowed.