Here is how you can quickly run applications or custom batch scripts from anywhere in Windows
The Windows GUI may be intuitive and useful for the general user, allowing them to easily perform a task through the traditional click-and-point, window-ed graphical interface, but it also limits things for pro users, reducing the speed and efficiency with which they can perform certain tasks. The text-based Command Line Interface has been the preferred form of user-computer interaction for professional users since the invention of computers and for most users, it is still the preferred interface.
One benefit of having a console interface is the ability to run a command from anywhere. For example, you can easily run an application or even a custom batch script from anywhere in Windows.
What is a batch script file?
A Batch file is a form of script file written in Microsoft’s DOS, OS/2 and Windows line of operating systems. It stores a series of commands in an executable form, and can be executed by the command-line interpreter. One key characteristic of batch files is that they are stored in plain text. The term batch comes from batch processing, which means ‘non-interactive execution’.
A batch file allows you to run multiple commands and automate tasks very easily. A batch file is like any executable file and all you have to do is execute it by double-clicking on it. Alternatively, you can also use a CLI like Command Prompt to run it.
How-To Run an Application or a Batch File from Anywhere in Windows
There are two ways you can run an application or a batch file from anywhere in Windows: the Run dialog box or a CLI like the Windows Command Prompt or PowerShell. However, by default, these programs search for a program in the environment variables specified by the system.
You will need to add a custom path so when you try to launch a program, Windows will be able to search over there. Here’s how you can do it,
Creating a Script File
- Create a script file and save it in a folder. For example, we will be creating a script file that can launch three programs at once.
@echo offstart chromestart notepadstart downloadsexit
- Now, save it in the folder as shown below. We will be creating a Scripts folder in Downloads and save the file over there.
Add the Folder to the System PATH Variable
- Type Start and search for advanced system settings and click on the first result. If you can’t see this option, alternatively, you can go to the Control Panel, click on System and Security, then click on System and then click on Advanced system settings from the settings on the left.
- Click on Environment Variables.
- From the list of options on the top, click on Path and click on Edit, as shown in the screenshot below.
- It will list down all the currently added directories to the Path variable. Click on New to add a new directory to the list and paste the path of the directory you just created.
Note: You can read our detailed guide for adding to the System PATH variable over here.
Any file saved over here in this folder is now quickly accessible from the Run dialog box or a CLI.
Executing the File from the Run Box
- Press Start + R to open the Run dialog box.
- Type start.bat or start, depending on what you named your script file. The file should execute the script and launch the three programs as instructed in the script.
Executing the File from the Command Prompt
- Search for cmd from the Start menu and click on it to launch the Windows Command Prompt.
- Type start.bat or start, depending on what you named your script file. The file should execute the script and launch the three programs as instructed in the script.
Note: If you have multiple files of the same name in any of the system path variables, the other file may be executed. The order in which the environment variables are saved matters and the path that is added above will be searched first. You can change the order in the environment variables settings.