How to run any given program from the command prompt?

Hey cplusplus.com

I was wondering how to run any given program right from the command prompt window. I was told that using the keyword "start" and then any program name ".exe" would do the trick. Unfortunately this didnt work.

Lets say i just installed this 3D program Blender. Its stored in my program files. Wouldnt it make sense to type in to the command prompt,
"start blender.exe" ?

It says windows cannot find blender.exe

----------------------------------------------------------------------
HELP PLEASE, I WOULD LIKE TO LEARN HOW TO OPEN ANY PROGRAM RIGHT FROM THE COMMAND PROMPT WINDOW. THANKS :]
----------------------------------------------------------------------



Type the name of the file that is the executable.

Here is a sample. Note that I changed directory to the directory contianing the executable.

C:\>cd "Program Files"

C:\Program Files>cd PuTTY

C:\Program Files\PuTTY>dir
 Volume in drive C has no label.
 Volume Serial Number is A4BD-BFE8

 Directory of C:\Program Files\PuTTY

22/05/2012  21:00    <DIR>          .
22/05/2012  21:00    <DIR>          ..
10/12/2011  12:35             1,318 LICENCE
10/12/2011  12:35           139,264 pageant.exe
10/12/2011  12:35           303,104 plink.exe
10/12/2011  12:35           315,392 pscp.exe
10/12/2011  12:35           327,680 psftp.exe
10/12/2011  12:35           446,930 putty.chm
10/12/2011  12:35            32,093 putty.cnt
10/12/2011  12:35           483,328 putty.exe
10/12/2011  12:35           657,290 putty.hlp
10/12/2011  12:35           180,224 puttygen.exe
23/01/2007  11:38             1,623 README.txt
22/05/2012  21:00             5,977 unins000.dat
22/05/2012  21:00           721,838 unins000.exe
16/11/2004  22:14               103 website.url
              14 File(s)      3,616,164 bytes
               2 Dir(s)  347,858,731,008 bytes free

C:\Program Files\PuTTY>Putty.exe

Hey , i get this when i enter the first line to point the directory to my program files.

"The system cannot find the path specified"

Isnt there a way that i can run a search+find command to run a .exe or .txt or .bat file without having to be so specific about the directories? Something like the search bar that sits at the bottom of the start menu.

If anyone can recommend some up-to-date COMMAND-LINE literature that would be great.
The fundamentals of the Windows Command Interpreter have not changed in quite a long time. Almost any reference that you will find on line will be essentially up to date.

Since you had trouble with the "cd" command, you should probably start at the beginning. The Interpreter environment is not very complex, but you do need to understand a few basic concepts.

File systems (file names, file paths)
The working directory
Environment variables
The default search path


The start command, however, if often poorly covered. It uses the same file association information stored in the registry that is used by Windows Explorer, and it also uses registry information to find the executable file for application not in the default search path.
I really don't understand how this is linked with C++, what you really want is a tutorial about batch scripting, which is a different programming language.

In C++ we use directly system calls like CreateProcess() to launch an executable, not using any command prompt, which btw is just a regular executable itself.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
if u want write some code to run another program in directory ("c:\\")

u can use this code in c++
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <urlmon.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;

int Main()
{
	
	ShellExecute(NULL,_T("Open"),_T("C:\\SchCache\\test.jpg"), NULL, NULL, SW_SHOWNORMAL);
	return 0;
}

Or
 
system("my_exe.exe");


Mani
Topic archived. No new replies allowed.