• Tips for the Command Prompt

    Home » Forums » AskWoody support » Windows » Windows – other » Tips for the Command Prompt

    Author
    Topic
    #2404452

    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:))

    1 user thanked author for this post.
    Viewing 5 reply threads
    Author
    Replies
    • #2404460

      I recommend using Windows Terminal. You can set Command Prompt, Powershell, or some other shell as your default. You can easily open multiple windows for the same or different shells within Windows Terminal.

      See Windows Terminal Tips and Tricks – Windows Command Line (microsoft.com) and Windows Terminal command line arguments | Microsoft Docs for much more information.

      --Joe

      2 users thanked author for this post.
    • #2404461

      Locate an old DOS manual for commands, explanation, and usage.

      These commands are also used in batch (.BAT) files.

      On permanent hiatus {with backup and coffee}
      offline▸ Win10Pro 2004.19041.572 x64 i3-3220 RAM8GB HDD Firefox83.0b3 WindowsDefender
      offline▸ Acer TravelMate P215-52 RAM8GB Win11Pro 22H2.22621.1265 x64 i5-10210U SSD Firefox106.0 MicrosoftDefender
      online▸ Win11Pro 22H2.22621.1992 x64 i5-9400 RAM16GB HDD Firefox116.0b3 MicrosoftDefender
    • #2404463

      Additional request: In Command Prompt Tips, please remove extra vertical spaces, remove HTML, and remove this note. Thank you.

      On permanent hiatus {with backup and coffee}
      offline▸ Win10Pro 2004.19041.572 x64 i3-3220 RAM8GB HDD Firefox83.0b3 WindowsDefender
      offline▸ Acer TravelMate P215-52 RAM8GB Win11Pro 22H2.22621.1265 x64 i5-10210U SSD Firefox106.0 MicrosoftDefender
      online▸ Win11Pro 22H2.22621.1992 x64 i5-9400 RAM16GB HDD Firefox116.0b3 MicrosoftDefender
      1 user thanked author for this post.
      • #2404477

        I paste from a Word document into the Visual box.  When I paste into the Visual box the extra vertical lines and HTML coding does not display.  After I click to post the posting appears as it is.  Is there something I can do to prevent this?  I’m sorry to offend you with my lack of knowledge in my posting style, but I am willing to learn if someone would direct me where to learn.  Other forums I post at do not function this way, and it is new to me.

         

        Dana:>>

        HTH, Dana:))

        • #2404481

          You can edit the reply after it’s posted and remove the extra spaces and HTML coding. See the Edit button below the reply.
          You can paste into the “Text” tab instead of the “Visual” tab, so you can see the HTML if it’s there.

          • #2404487

            Thank You.  I understand the editor needs plain text.

            I could not Edit the first posting as the option to edit is no longer there.  The Edit function is available for my second posting, but not the first posting.  I’m sorry that my posting style tarnished my attempt to provide some useful tips to some readers and I’ve learned from it.

             

            Dana:>>

            HTH, Dana:))

        • #2404483

          Another option: after doing the same thing as you, I learned to first write my posts in Notepad (or similar text editor) first, and then copy and paste into the Visual box. I’ll then double-check for proper spacing before hitting the “Submit” button.

          Win 7 SP1 Home Premium 64-bit; Office 2010; Group B (SaS); Former 'Tech Weenie'
        • #2404492

          Another tip. If you hold down the “Shift” key when you hit “Enter,” you get a single space between lines instead of double spacing.

    • #2404482

      There are two tabs at the top of the edit box:
      Visual
      Text
      Make sure you view all your input as text, make corrections, and only then submit.

      Less than sign, greater than sign (the pointed symbols) indicate HTML. HTML confuses the WordPress editor because it is code. Remove it. The exceptions are links — them you leave alone.
      Here is a link:
      https://www.askwoody.com/forums/topic/tips-for-the-command-prompt/

      Avoid underlining anything that appears on a webpage. Links are always underlined, although you may have to hover over them to see the underline. Links are also color-coded.

      You have HTML underline commands throughout your post.

      On permanent hiatus {with backup and coffee}
      offline▸ Win10Pro 2004.19041.572 x64 i3-3220 RAM8GB HDD Firefox83.0b3 WindowsDefender
      offline▸ Acer TravelMate P215-52 RAM8GB Win11Pro 22H2.22621.1265 x64 i5-10210U SSD Firefox106.0 MicrosoftDefender
      online▸ Win11Pro 22H2.22621.1992 x64 i5-9400 RAM16GB HDD Firefox116.0b3 MicrosoftDefender
    • #2404495

      The GoTo place for tutorials of this nature (and almost anything to do with Windows 10) is the inimitable Shaun Brink’s Windows 10 Forums, heavily illustrated by commented screen prints.
      There is lots about opening an Elevated Command Prompt in this tutorial, and a large number of links to related tutorials at the bottom.

      BATcher

      Plethora means a lot to me.

      1 user thanked author for this post.
    • #2418305

      The Copy Path command sounds like a really handy tool! What a major hassle it has been all these decades to have to type in the entire path without any typos! I don’t know how I missed that one.

      As for copying from Word to Visual Box as plain text, have a blank Notepad document open; copy from Word; paste into Notepad; copy from Notepad; paste into Visual Box.

      There are lots of times when you want to strip away the formatting from some text you copy either from a Word document, an Excel spreadsheet, a web site, or many other places. Notepad is an excellent tool for doing this.

      Once you get into the habit of using Notepad in this way to strip out the formatting, it takes no time at all to do it.

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
      • #2418357

        What a major hassle it has been all these decades to have to type in the entire path without any typos!

        I type one or two characters and press Tab. Windows fills in the rest and subsequent Tabs move to the next match. Add a backslash and Tab to go down another level.

        cheers, Paul

        2 users thanked author for this post.
        • #2419857

          I’m still learning DOS after all these years!

          Group "L" (Linux Mint)
          with Windows 10 running in a remote session on my file server
    Viewing 5 reply threads
    Reply To: Tips for the Command Prompt

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: