- How to Run Program from CMD (Command Prompt) Windows 10 [MiniTool News]
- Summary :
- How to Run a Program from CMD in Windows 10
- How to Run EXE in CMD on Windows 10
- Bottom Line
- ABOUT THE AUTHOR
- START
- Start — run in parallel
- Start /Wait
- START vs CALL
- Run a program
- Multiprocessor systems
- Running executable (.EXE) files
- Command Extensions
- Errorlevels
- I need to run program from cmd, using variable on windows 7
- 2 Answers 2
How to Run Program from CMD (Command Prompt) Windows 10 [MiniTool News]
By Alisa | Follow | Last Updated June 10, 2020
Summary :
You can run a program or an exe file from Command Prompt. Check how to do it in this tutorial. MiniTool software, not only provides many useful computer solutions, but also provides users many useful computer software like data recovery program, disk partition manager, system backup and restore software, video editor, etc.
If you want to run program from CMD (Command Prompt) on Windows 10, you can check the detailed steps below.
How to Run a Program from CMD in Windows 10
You can only run the applications that are installed in Windows-created folders like Explorer in Command Prompt.
Step 1. Open Command Prompt in Windows 10
At first, you should open Command Prompt application on your Windows 10 computer. You can press Windows + R, type cmd, and press Enter to open normal Command Prompt or press Ctrl + Shift + Enter to open elevated Command Prompt on Windows 10.
Learn how to open a file/folder in Command Prompt (cmd) on Windows 10. Step-by-step guide is included.
Step 2. Run Program from CMD on Windows 10
Next you can type start
command in Command Prompt window, and press Enter to open the target application in CMD. Replace the “program name” with the exact file’s system name of the program but not its shortcut name. For instance: start explorer.
The file’s system name of some common programs in Windows are as follows:
- Command Prompt: cmd
- File Explorer: explorer
- Task Manager: taskmgr
- Calculator: calc
- Notepad: notepad
- Paint: mspaint
- Windows Media Player: wmplayer
How to Run EXE in CMD on Windows 10
You can follow the instructions below to run an exe file in Command Prompt.
Step 1. Access Command Prompt window
You can follow the same operation above to open Command Prompt in Windows 10.
Step 2. Navigate to the folder of the target program
Next you can type cd command in Command Prompt window, and press Enter to navigate to the folder that contains the target exe application. Replace “file path” with the exact file path of the exe file.
You can find the target program folder and click the address bar at the top of File Explorer window to copy the path of the program folder and paste it after cd command. For example, cd C:\Program Files\Windows Media Player.
Step 3. Run exe from CMD
After you are in the target program folder path, then you can type start after the selected file path in CMD, and press Enter to run the exe file in Command Prompt. Replace “filename.exe” with the target program name, e.g. start wmplayer.exe.
Bottom Line
This post introduces how to run a program or exe file from CMD on Windows 10. Hope it helps.
If you need a free data recovery software to recover deleted/lost files from Windows 10 computer or other storage devices, you can try MiniTool Power Data Recovery.
MiniTool Power Data Recovery is a Windows data recovery program that allows you to recover data from PC, external hard drive HDD or SSD, USB drive, SD card, memory card, and more. It is very simple to use and 100% clean.
ABOUT THE AUTHOR
Position: Columnist
Alisa is a professional English editor with 4-year experience. She loves writing and focuses on sharing detailed solutions and thoughts for computer problems, data recovery & backup, digital gadgets, tech news, etc. Through her articles, users can always easily get related problems solved and find what they want. In spare time, she likes basketball, badminton, tennis, cycling, running, and singing. She is very funny and energetic in life, and always brings friends lots of laughs.
START
Start a program, command or batch script, opens in a new window.
Always include a TITLE this can be a simple string like «My Script» or just a pair of empty quotes «»
According to the Microsoft documentation, the title is optional, but depending on the other options chosen you can have problems if it is omitted.
If command is an internal cmd command or a batch file then the command processor is run with the /K switch to cmd.exe. This means that the window will remain after the command has been run.
In a batch script, a START command without /wait will run the program and just continue, so a script containing nothing but a START command will close the CMD console and leave the new program running.
Document files can be invoked through their file association just by typing the name of the file as a command.
e.g. START «» MarchReport.DOC will launch the application associated with the .DOC file extension and load the document.
To minimise any chance of the wrong exectuable being run, specify the full path to command or at a minimum include the file extension: START «» notepad.exe
If you START an application without a file extension (for example WinWord instead of WinWord.exe) then the PATHEXT environment variable will be read to determine which file extensions to search for and in what order.
The default value for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD
Start — run in parallel
The default behaviour of START is to instantiate a new process that runs in parallel with the main process. For arcane technical reasons, this does not work for some types of executable, in those cases the process will act as a blocker, pausing the main script until it’s complete.
In practice you just need to test it and see how it behaves.
Often you can work around this issue by creating a one line batch script ( runme.cmd ) to launch the executable, and then call that script with START runme.cmd
Start /Wait
The /WAIT option should reverse the default ‘run in parallel’ behaviour of START but again your results will vary depending on the item being started, for example:
The above will start the calculator and wait before continuing. However if you replace calc.exe with Winword.exe , to run Word instead, then the /wait will stop working, this is because Winword.exe is a stub which launches the main Word application and then exits.
A similar problem will occur when starting a batch file, by default START will run the equivalent of CMD /K which opens a second command window and leaves it open. In most cases you will want the batch script to complete and then just close it’s CMD console to resume the initial batch script. This can be done by explicitly running CMD /C .
Add /B to have everything run in a single window.
In a batch file, an alternative is to use TIMEOUT to delay processing of individual commands.
START vs CALL
Starting a new process with CALL, is very similar to running START /wait , in both cases the calling script will (usually) pause until the second script has completed.
Starting a new process with CALL, will run in the same shell environment as the calling script. For a GUI application this makes no difference, but a second ‘called’ batch file will be able to change variables and pass those changes back to the caller.
In comparison START will instantiate a new CMD.exe shell for the called batch. This will inherit variables from the calling shell, but any variable changes will be discarded when the second script ends.
Run a program
To start a new program (not a batch script), you don’t have to use CALL or START , just enter the path/file to be executed, either on the command line or within a batch script. This will behave as follows:
- On the command line, CMD.EXE does not wait for the application to terminate and control immediately returns to the command prompt.
- Running a program from within a batch script, CMD.EXE will pause the initial script and wait for the application to terminate before continuing.
- If you run one batch script from another without using either CALL or START , then the first script is terminated and the second one takes over.
Multiprocessor systems
Processor affinity is assigned as a hex number but calculated from the binary positions (similar to NODRIVES)
Hex Binary Processors
1 00000001 Proc 1
3 00000011 Proc 1+2
7 00000111 Proc 1+2+3
C 00001100 Proc 3+4 etc
start /NODE 1 app1.exe
start /NODE 1 app2.exe
These two processes can be further constrained to run on specific processors within the same NUMA node.
In the following example, app1 runs on the low-order two processors of the node, while app2 runs on the next two processors of the node. This example assumes the specified node has at least four logical processors. Note that the node number can be changed to any valid node number for that computer without having to change the affinity mask.
start /NODE 1 /AFFINITY 0x3 app1.exe
start /NODE 1 /AFFINITY 0xc app2.exe
Running executable (.EXE) files
When a file that contains a .exe header, is invoked from a CMD prompt or batch file (with or without START), it will be opened as an executable file. The filename extension does not have to be .EXE. The file header of executable files start with the ‘magic sequence’ of ASCII characters ‘MZ’ (0x4D, 0x5A) The ‘MZ’ being the initials of Mark Zibowski, a Microsoft employee at the time the file format was designed.
Command Extensions
If Command Extensions are enabled, external command invocation through the command line or the START command changes as follows:
Non-executable files can be invoked through their file association just by typing the name of the file as a command. (e.g. WORD.DOC would launch the application associated with the .DOC file extension). This is based on the setting in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ext\OpenWithList , or if that is not specified, then the file associations — see ASSOC and FTYPE.
When executing a command line whose first token is the string CMD without an extension or path qualifier, then CMD is replaced with the value of the COMSPEC variable. This prevents picking up CMD.EXE from the current directory.
When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the COMSPEC environment variable. This prevents picking up CMD.EXE from the current directory.
When executing a command line whose first token does NOT contain an extension, then CMD.EXE uses the value of the PATHEXT environment variable to determine which extensions to look for and in what order. The default value for the PATHEXT variable is: .COM;.EXE;.BAT;.CMD Notice the syntax is the same as the PATH variable, with semicolons separating the different elements.
When searching for an executable, if there is no match on any extension, then looks to see if the name matches a directory name. If it does, the START command launches the Explorer on that path. If done from the command line, it is the equivalent to doing a CD /D to that path.
Errorlevels
If the command is successfully started ERRORLEVEL =unchanged , typically this will be 0 but if a previous command set an errorlevel, that will be preserved (this is a bug).
If the command fails to start then ERRORLEVEL = 9059
START /WAIT batch_file — will return the ERRORLEVEL specified by EXIT
Run a minimised Login script:
START «My Login Script» /Min Login.cmd
Start a program and wait for it to complete before continuing:
START «» /wait autocad.exe
Open a file with a particular program :
START «» «C:\Program Files\Microsoft Office\Winword.exe» «D:\Docs\demo.txt»
Open Windows Explorer and list the files in the current folder (.) :
C:\any\old\directory> START .
Open a webpage in the default browser, note the protocol is required (https://)
START https://ss64.com
Open a webpage in Microsoft Edge:
%windir%\explorer.exe microsoft-edge:https://ss64.com
Connect to a new printer: (this will setup the print connection/driver )
START \\print_server\printer_name
I need to run program from cmd, using variable on windows 7
i need to run new-installed program from command prompt on windows 7 like it is posibble for notepad calc or some other windows-basic program. How i can do that? I tryed to use enviroment variables but i fell in stuck with it. Is there a way for something like this ?
2 Answers 2
try like this command
start c:\»Program Files»\VideoLAN\VLC\vlc.exe
quote must need for the the file/folder name which is having space
So according to the comments to your question, you now managed to start your program from whereever you are by including it’s path to the %path% variable.
Your new error «Unable to run package setup. Failed to load module. ImportErorr: No module named Package setup» comes from your program, which fails to load some of it’s modules.
That’s because it looks for them in the current working directory. (where you are, not where the program and it’s modules are stored)
Create a short batchfile in the program’s folder:
Save it as «program.bat» (if you just enter «program», it will look first, if there is a .bat and starts that instead of an .exe with the same name).
The first line changes the current working directory to the file, where that .bat (and the program and it’s modules) resides, the second line just starts the program itself.