news

Automatically Execute CMD Commands through a Small File on the Desktop

Always, the command prompt environment “cmd” in Windows offers many useful commands that you can use to accomplish tasks faster and solve many problems when it is difficult to do so through the user interface. However, some people prefer not to use the command prompt environment, as many find it difficult to remember the commands and type them repeatedly.

So, through this article, we will provide a great trick that you can use to create a shortcut for the most frequently used “cmd” commands, allowing you to run those commands with a single click on the desktop without the need to open the command prompt and manually type the commands each time. You can also assign a direct shortcut for those commands from the keyboard to execute them quickly.

 


The idea is simply to create a “Shortcut” for the command prompt environment “cmd” by specifying a specific command from the “cmd” commands to be executed when clicking on that shortcut and running it directly without the need to open the command prompt and type the command as in the traditional use of “cmd”.

To do this, right-click on the mouse on the desktop, then click on “New” and then “Shortcut” to create a new shortcut. In the next window, you will need to specify a link for that shortcut, and we will enter the link for the “cmd” interface followed by “k/” and then the command you want to execute directly through the shortcut.

For further clarification, for example, if you want to create a shortcut to execute the “ipconfig” command, which allows you to view network connection information including the computer’s IP address and other information, the shortcut link would be as follows:

C:\Windows\System32\cmd.exe /k ipconfig


You can insert any command you want to execute after “k/”, for example, you can include the command “sfc/scannow” which is used to scan system files and repair any errors in them, and in this case, the command would be as follows:

C:\Windows\System32\cmd.exe /k sfc /scannow

After specifying the link as you want in the first step, click on “Next”, and in the next step, you can specify any name you want for that shortcut. In this example, we will choose the name “IP Configuration,” then by clicking on “Finish,” the shortcut will be created on the desktop, but you can also move it to any other location on the computer if desired.

After creating the shortcut, you can do some additional cool things, such as customizing a shortcut from the keyboard to run the shortcut you created and execute the command through the keyboard. By right-clicking on the shortcut you created, then clicking on “Properties,” and then navigating to the “Shortcut” tab in the following window, you can specify a shortcut to execute the command directly by pressing inside the “Shortcut Key” box and then pressing the keys you want to customize from the keyboard, provided that one of those keys is the ALT key or CTRL key or both in addition to any third key.

Also, by clicking on “Advanced” in the same menu, then activating the “Run as administrator” option, you can open the shortcut with administrator privileges, which will be very useful if you want to create a shortcut for one of the “cmd” commands that require administrator privileges to execute and work without problems.

After that, when you open the shortcut either by clicking with the mouse or using a keyboard shortcut you customized in the previous step, the command prompt window will open and execute the command you specified directly, showing the result of this command immediately, which is a great trick that will save you a lot of time when using “cmd”.


You can also run this shortcut automatically at the start of the computer and when entering the Windows system by copying the shortcut and pasting it into the following path:

C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

Then, when you turn on or restart the computer at any time, the shortcut will be executed automatically and the command you specified by the path of that shortcut will be executed as soon as you enter the operating system, and if you want to cancel that command at any time, simply go to the same path and remove or delete the shortcut from it.

Leave a Reply

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

Back to top button
error: Content is protected !!