Run .exe file from command prompt using batch script
This article will show you how to use a batch (.bat) script to run a .exe type file.
You can use two different commands to achieve this. Let’s discuss each method in the following sections.
Run .exe file from command prompt using title and location using batch script
If you know the window title of the file and know the exact location, you can use a command of the following format.
start "Windows Title" c:\Location\file.exe
The following example opens the notepad.exe file.
Sample code:
start "Notepad" c:\windows\system32\notepad.exe
Run .exe file from command prompt using batch script using location and file name
You can also open a .exe file using the following command. To use this command, you need the location and file name.
The general format of the method is shown below.
start "c:\location" file.exe
We will use this command to open notepad.exe.
Sample code:
start "c:\windows\system32" notepad.exe
Keep in mind that all methods discussed here are written using batch scripts and will only work with Windows CMD.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Article URL:https://www.jiyik.com/en/xwzj/opersys_9923.html
Related Articles
Deleting files older than N days using batch script
Publish Date:2025/03/20 Views:57 Category:OPERATING SYSTEM
-
In this article, we will use a batch script to delete files older than N days. Deleting files older than N days using batch script The general format of the code to perform this task is shown below. FORFILES /p "D:\DIRECTORY" /S /M *.* /D -
Deleting files using batch script
Publish Date:2025/03/20 Views:178 Category:OPERATING SYSTEM
-
This article will demonstrate how to delete files using a batch script. Deleting files using batch script Generally, we can easily delete files by clicking on delete or pressing the delete button on the keyboard. But in Batch, we have to fo
Concatenate multiple files using batch script
Publish Date:2025/03/20 Views:195 Category:OPERATING SYSTEM
-
In this article, we will see how to concatenate multiple files into one file. Concatenate multiple files using batch script The general format of the commands we will use is shown below. type FileONE.txt FileTWO.txt ConcatFile.txt There are
Running multiple files in a batch script
Publish Date:2025/03/20 Views:55 Category:OPERATING SYSTEM
-
Large scripts contain multiple files because it is easy to maintain the code. When working with larger scripts, you may want to divide them into modules to make it easier to detect any coding errors or problems. However, Batch does not have
Difference between % and %% in batch files
Publish Date:2025/03/20 Views:200 Category:OPERATING SYSTEM
-
Batch programmers often confuse single percent signs (%) and double percent signs (%%) when used in batch files. The FOR command uses %f when executed on the command line, but in a batch file, it uses %%f instead of a single percent sign. T
Error handling in batch scripts
Publish Date:2025/03/20 Views:127 Category:OPERATING SYSTEM
-
Every scripting and programming language contains error handlers, for example Java contains try-catch for error handling. In batch scripts, there is no direct way to do this, but we can create error handlers in batch scripts using the built
Waiting for commands in a Windows batch file to finish executing
Publish Date:2025/03/20 Views:98 Category:OPERATING SYSTEM
-
There are multiple commands and installation processes in a batch file, which usually takes some time to complete. However, when a batch file is run, it does not wait for the command process to complete; it executes all the commands line by
Redirecting output to a text file from within a batch file
Publish Date:2025/03/20 Views:186 Category:OPERATING SYSTEM
-
This article will explain different ways to redirect output from a text file. Redirection operators in batch scripts We can redirect the output of a batch file to a text file using redirection operators. Redirection operators redirect the i