-->

Run Command Prompt Commands from Windows Shortcut | You can definitely do it yourself.

How to Run Command Prompt Commands from Windows Shortcut

 Did you know that you can use shortcuts to execute commands from the Command Prompt? Here's how to do it:


1. Create a shortcut by right-clicking anywhere in File Explorer or your desktop and selecting New > Shortcut.


559x247xcps_1


2. In the “create shortcut” window, type your command using the following syntax:

"C:\Windows\System32\cmd.exe" /k yourcommand


The first part (the part in quotes) calls cmd.exe to open the Command Prompt. The “/k” tells the Command Prompt to issue a command to follow, and then it stays open so you can see the result or type the next command. You can also use “/c” if you want the Command Prompt window to close after issuing a command. And of course, the “yourcommand” part is the command you want to run.


For example, if you wanted to create a simple command to run the system file checker to find and fix problems with system files, you would type the following command:

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


 614x454xcps_2


3. Once you have finished creating the command, click “Next.”


4. Type a name for the shortcut and then click “Finish.”


614x454xcps_3


Now, you just run the shortcut and no longer need to open Command Prompt and type commands manually every time.


Another thing the shortcut can do is save the command results to a text file (or other program). For example, you want to run the command “ipconfig /all”, and want the results to be saved in a file called ipconfig.txt on your desktop, and after that close the command prompt. Then you can use the following command:

"C:\Windows\System32\cmd.exe" /c ipconfig /all > "c:\users\username\Desktop\ipconfig.txt"


650x367xcps_4-650x367


And done!

Related Posts