Tips for the Command Prompt
Purpose:
Tips that make using the Command Prompt easier.
Overview:
If you use the Command Prompt in Windows even occasionally, you will find the following tips will help you. Each tip below is explained.
<u>Open Admin Command Prompt with One Click:</u>
A lot of commands used in a Command Prompt require the Command Prompt to have Administrative privileges in order to run the command, so it is best to always open the Command Prompt with Administrative privileges. The various ways to open a Command Prompt each involve several steps and for opening with Administrative privileges the User Account Control box opens requiring authorization if you have not deactivated that security feature (I suggest you leave it active). This tip will create a shortcut that will open a Command Prompt with Administrative privileges without the UAC box opening, thus opening a ready to go Administrator Command Prompt with only a single click.
This tip is composed of two parts – a scheduled task and a desktop shortcut. The task is used to open a Command Prompt with pre-authorized Administrative privileges which negates the UAC box opening and waiting for a response. The shortcut is used to run the task without having to open the Task Scheduler. The result is click the shortcut once and a Command Prompt with Administrator privileges will open ready to use.
<u>Create the “Scheduled Task”</u>
- Open the Task Scheduler – open a Run box (WinKey + R) and enter msc.
- From Task Scheduler top menus, select Action> Create Task… to open the Create Task
- On the General tab:
- Enter ADCMD in the Name: (You can use any name you want)
- Under Security options, put a checkmark in the box next to Run with highest privileges (this setting is the pre-authorization that negates a UAC confirmation window).
- In the Configure for: box use the dropdown arrow to select your version of Windows (Windows 10 for my example).
- Select the Actions tab and click the New… button to open the New Action
- In the New Action window, select Start a program for the Action: In the Program/script box enter the location of cmd.exe which by default is C:\Windows\System32\cmd.exe
- Press OK to save your newly created task. It will show in the list of tasks in top center portion of the Task Scheduler. Test the new task by right clicking and selecting Run. The Administrator Command Prompt should open.
<u>Create the Shortcut To the Task</u>
- Right click a blank spot on the Desktop and select New> Shortcut, which will open the Create Shortcut wizard.
- In the Type the location of the item: box, enter
C:\Windows\System32\schtasks.exe_/run_/tn_”ADCMD”
Replace the underscores (_) with a space.
- Press the Next button
- Enter a Name for the shortcut…I named it Command
- Click Finish button to finish and place the shortcut on the Desktop. You can move the shortcut anywhere you want. I have a folder containing shortcuts to most of Windows Utility programs which I attached to the Taskbar as a toolbar. One click to open any of these programs.
<u>Easy/Accurate Way To Enter PATHs in a Command</u>
Typing in a PATH address in a command is a tedious and error prone process, and we all have had a command failed to run because the PATH was entered wrong by a single character or space, not to mention that is the address had a space in the address the whole address needed to be in quotation marks. This tip explains how to use Windows to copy and paste multiple PATH addresses into the Command Prompt to save typing and increase accuracy.
Open File Explorer and go to the folder/file you want the PATH address for and highlight it (selected but not opened). On the Home tab in the ribbon above click Copy path, which will copy the PATH address with quotation marks (ready to be pasted and used). Repeat and copy all the PATH addresses you will need including the addresses to the folders for generated reports, as you can add the report file after you pasted the first part of the address. You can copy up to 25 different PATH address. See the side tip below for creating a keyboard shortcut to Copy path in File Explorer.
To paste your copied PATH addresses in the Command Prompt, place the cursor in the command where the PATH goes and open the Clipboard Manager with WinKey + V. The clipboard Manager will display the PATHs that you copied and click the address you want. The address will be pasted into the command. Once pasted, you can edit as you need such as add a file which will be a report. PATH addresses that you use a lot (like an export folder) can be pinned in the clipboard and always be there for you.
Side Tip – Keyboard Shortcut for Copy path in File Explorer
Open File Explorer. On Home tab of ribbon right click Copy path and select Add to Quick Access Toolbar, which will add it to the Quick Access Toolbar at the top. It will be the last icon added. To use: Highlight the file/folder, press the Alt key and numbers will appear under each icon in the Quick Access Toolbar. Press the number for the Copy path (on my setup it is 4) and the PATH will be copied. You can open the Clipboard Manager (WinKey+V) and check to see if the PATH was copied.
<u>Keep a Copy of a Command Prompt Session</u>
Having a copy of all the commands entered and responses displayed can be very helpful in “figuring out what went wrong”. When things don’t go like you expected them to, then make a copy of the Command Prompt session for detailed review. Since a Command prompt session is one long, continuous page, it can be easily copied.
To copy: Press Ctrl + A to select all text in the Command Prompt. Open a text editor and Paste into a blank document. Name it accordingly and save to your drive. You can review the session in detail and even used search functions of a text editor.
I welcome others to add to this list. Learning from others is the easiest way to learn.
HTH, Dana:>>
HTH, Dana:))