Create Your Own Shortcuts Using Batch File

Till now all the tutorials are the basics that you need to start with batch files. From now, we are going to jump into some fascinating real world applications and some important commands that makes using your Windows PC much easier and comfortable than ever. We will also peep through how to build these scripts, use them, and obviously you will also know how they work.

Start Command in Batch File

Syntax 


START [“title”] [/D path] [/I] [flags specifying state of window] [flags specifying memory space of program] [priority flags] [/NODE <NUMA node>] [/AFFINITY <hex affinity mask>] [/WAIT] [/B] [command/program] [parameters]

‘Start’ command is helpful when we require starting a new program window or a command prompt. All the run line commands can be started using this start command in our program. You can see that start command has a very large syntax, but it is pretty simple enough to understand. Let us break it down and deal with a single piece at a time.

Start
We use simply start command without any parameters or flags starting a new command prompt in the current directory.

Title
The first part is the “Title”. It is specified in quotes, the title is used to display a specified title in window title bar. If you can remember, we already discussed in the previous post.

Eg: start “My Shell”

The above command starts a new command prompt titled as “My shell”.

Path
The path is used with the flag /D to specify the starting directory when you start a new command prompt using simply start command.


Eg: start /d “C:Userscrazyprogrammer”

Starts a new command prompt with starting directory as the specified one above

I
This flag tells that the new environment will be the original environment passed to command prompt initially and not the current executing environment of the program.

State of window
We have two flags to specify the state of a window that is being started by the start command. ‘/MIN’ starts the new window in a minimized state, whereas ‘/MAX’ flag specifies the state of windows to be in a maximized state.’/max’ and ‘/min’ switches open up new command prompt either maximized or minimized based on flag used, if no application is specified.

Eg: start /max mspaint

This command opens up MSPaint application with the windows state maximized. You can try similarly for min switch.

B
‘/b’ flag is used to start application on the same console without creating a new window. It’s similar to having two command prompts at the same time. Once you start new command prompt, typing exit will terminate the current one and open up the previous prompt but will not close the window entirely. The application that has been opened up has ^C handling ignored, unless the application enables ^C processing, to interrupt the application ^Break is the only way.

Memory space
Next comes the switch to specify the memory space of a program. Often it is necessary to specify the memory space of the windows programs. ‘/SEPARATE switch starts a 16-bit Windows program in separate memory space. ‘/SHARED’ switch allocates shared memory for all the programs.

Eg: start /shared write

The above command is used for opening a WordPad in a shared memory space.

Priority switches
If you are familiar with the multithreading and concurrent processing in operating systems, you might have known that there are basically 4 priorities for any process to allocate the CPU. ‘/LOW’ switch starts an application and places it in IDLE priority class. ‘/NORMAL’ switch starts the application and assigns it a NORMAL priority. ‘/HIGH’ switch is used or applications that need CPU to be allocated urgently hence place them in HIGH priority class. ‘/REALTIME’ switch opens an application by setting its priority to REALTIME priority class. Similarly, we also have ‘/abovenormal’ and ‘/belownormal’ switches.

Eg: start /belownormal mshearts.exe

The above command opens up the “hearts” game with the below normal priority class with the priority which stays in between the normal and idle.

Batch program to open your favorite programs and websites easily
If you are a no voice user of windows and you want to use your PC like a pro, the below program helps you out. The basic idea behind creating the below program is we frequently be using different shortcuts and programs. Every time we need them, we need to go search them or we need to open up the start menu to get frequently listed programs. Instead of doing so, we can create a batch file to place all our shortcuts at one place.

Before getting into the program, I’d like to mention that I’ve given a list of run commands during the introductory lesson which might be helpful here.
The program is very simple enough to understand, I’ve used the simple start command without any switches here. You know how to run the below code. Copy it, save it as shortcuts.bat and double click to execute it. You can see the options displayed as a list on the command prompt as shown below.

Create Your Own Shortcuts Using Batch File

I’ve displayed all the options using simple echo commands. To collect the choice of the user, I declared a variable using /p flag for the set command

set /p choice=

Then using a series of if conditional checker, I’ve placed the programs in the respective sections like the one’s shown below.

if %choice%==1 (
start appwiz.cpl
)
if %choice%==2 (
start control
)

Isn’t awesome, Go and create your own shortcuts. I’d like to mention one thing here. This program lets’s you to open your favorite websites directly using the below command. One thing to note is the link opens up in your default browser that you have set in your computer.

Start [URL of website]


Eg: start http://www.crazyprorgammer.com

Entire Source Code





More Fun to Try
I’ve used simple start commands in the above batch file program, but I’d like you to try out all the flags and switches and test them.

Leave a Reply

Your email address will not be published. Required fields are marked *