locked
How to pin multiple Command Prompts to Task Bar? RRS feed

  • Question

  • Hello,

    I do a lot of work in Command Prompt windows, and frequently have multiple windows on the screen at the same time. To help my brain differentiate them quickly, I use five different text colors, as well as different positions on my desktop. For example, the window with yellow text is always on the left side of the desktop, and the one with the green text is on the right. I always run code (e.g. SQL, Python, etc.) in the yellow one, and write code in the green one.

    To facilitate opening new Command Prompts with the correct formatting, I have used a collection of shortcuts to cmd.exe on my task bar. After rebooting or when responding to a new bug report, for example, I can quickly open a bunch of windows to build up my desktop to a familiar and productive state.

    While I generally find the new Windows 7 task bar quite helpful, I cannot figure out how to reproduce this specific behavior - multiple Command Prompt shortcuts - that I used regularly in Vista, XP, and 2000. Specifically, I have tried:

    1. Create a second shortcut in a folder, and drag it to the task bar. When I create a second shortcut to cmd.exe and drag it over the task bar in an effort to pin it, I see the Ghostbusters symbol (red circle with slash). This disallows me from pinning the shortcut.

    2. Manually add a shortcut to %APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar. The new shortcut appears to be created correctly in this location; I am able to double-click it in Windows Explorer and launch the second Command Prompt. The second instance of the Command Prompt does not, however, appear as an independent shortcut on my task bar, nor as a chocie in the context menu (if that's what it's called?) for the existing pinned Command Prompt shortcut.

    3. Add a folder as a new toolbar. I read a thread that described how to add the old Quick Launch toolbar to the Windows 7 interface. This works for me, in that I can create multiple Command Prompt shortcuts on that toolbar. This is messy, though, in that the new toolbar is decoupled from the task bar, itself - it behaves exactly like the old Quick Launch / Task Bar UI in Vista and it's predecessors. I'd really like to stick with the Windows 7 style integrated taskbar.

    Therefore, my question is:

    Q: How do I add multiple Command Prompt (cmd.exe) shortcuts to my Windows 7 task bar - and maintian unique formatting (e.g. text color, window size, window position) for each shortcut?

    Ideally, I'd like separate buttons on the task bar, for quick access. If necessary, I'll settle for multiple shortcuts pinned to the context menu of the primary shortcut - like the Windows Explorer shortcut behaves when you pin multiple folders to the task bar.

    Thanks for helping with my pet peeve. I know that this probably isn't important to most users, but it's very important to my sanity and productivity. I appreciate your help.

    -Michael
    • Changed type Ronnie VernonMVP Thursday, December 17, 2009 7:00 PM Discussion
    • Changed type Ronnie VernonMVP Sunday, December 20, 2009 9:01 PM Question - Solution
    Tuesday, December 15, 2009 3:26 PM

Answers

  • I found a neat way.

    Since the limitation is that the TaskBar won't allow more than one instance of the same executable to be pinned to the taskbar, our task is to convince Windows 7 that we're pinning different executables, when in fact we're starting C:\WINDOWS\SYSTEM32\CMD.EXE in every case.

    The way to do this is with a "reparse point" or "junction".  http://en.wikipedia.org/wiki/NTFS  (look down the page for "Reparse points")

    Sysinternals has published a tool called JUNCTION that exposes little-known functionality in NTFS that will allow you to create what Unix users might call a "link" to a file or folder.  You can find the software here: 

    http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

    Basically, you can make reparse points that look like two different folders but which really point to the same place.  For the sake of argument call them C:\TEMP\SYSTEM32_1 and C:\TEMP\SYSTEM32_2.  I'm using C:\TEMP for testing, but you'll probably want to put these a folder somewhere safe, that's not going to get deleted, perhaps under your user area.  The commands for this are:

    JUNCTION  C:\TEMP\SYSTEM32_1  C:\WINDOWS\SYSTEM32

    JUNCTION  C:\TEMP\SYSTEM32_2  C:\WINDOWS\SYSTEM32

    Now you can make shortcuts to what the OS considers two separate executables (C:\TEMP\SYSTEM32_1\CMD.EXE and C:\TEMP\SYSTEM32_2\CMD.EXE) give them their own settings, and happily pin them to the task bar.  Best of all, both of these run the one and only CMD.EXE in the system folder.

    Enjoy!

    -Noel

    Thursday, December 17, 2009 8:19 PM
  • Hello, I didn't read the whole thread so this suggestion may already be there or not work for you.

    I tried the reparse thing, didn't work.  So I just copied cmd.exe to cmd1.exe.  You can do that as many times as you want and pin them all to the task bar.

    Friday, February 10, 2012 2:56 PM

All replies

  • You could restore the Quick Launch bar as it was in XP.  See this post by Ronnie Vernon, MS MVP here:  Please restore the Quick Launch (post #4)

    Rich
    Tuesday, December 15, 2009 10:55 PM
  • Make new Name.txt file in folder somewhere. Put your commands in proper sequence there. Rename it to Name.bat.

    On desktop make shortcut to Name.bat & drag it down to your toolbar.

    Wednesday, December 16, 2009 12:40 PM
  • Thank you for your prompt responses. I think, however, that I am still in the same boat. To reply individually:


    Rich, I can create a Quick Launch style toolbar, but I encounter the issue I describe in item #3 from my original post. (BTW, the post you recommended was the one that I originally read.)


    TheGonzoIsIn, I can create batch files with various 'cmd.exe' commands in them, but I run into two problems:
    • I cannot control most Command Prompt properties when I launch cmd.exe via a batch file. For example, I cannot (or do not know how to) toggle Quick Edit mode, specify a window size and position on the screen, or customize the length of the command recall buffer, among other things. To control these properties, I need to right-click a running Command Prompt or an existing task bar shortcut and click the Properties context menu choice. When I do this, though, the properties for all Command Prompt windows that are launched from all of my .bat files change together. For example, I can't seem to make one batch file that opens a window on the left of the screen, and a second batch file that opens a Command Prompt on the right. In the past, these properties were tied to new Command Prompt windows based on the window title. Now, changing a property for any Command Prompt changes the same property for all future instances.
    • I still get the Ghostbusters symbol when I try to pin one of the batch files to the task bar.
    I'm not sure why Command Prompt behaves this way in the Windows 7 task bar. When I drag a new folder to the task bar, I get a 'Pin to Windows Explorer' option. With Command Prompt, I just get the red circle/slash. (Actually, I get the Ghostbusters symbol for many things that I try to pin; I'm obviously not understanding the subtleties of the new task bar yet.)

    If there's really no other option, I'll revert back to a clean task bar (i.e. only running apps, no shortcuts) with an old-style Quick Launch bar. I hate to throw in the towel on the otherwise nice Windows 7 task bar just yet. If you have any other ideas to help keep my desktop in the modern age, I'd love to hear them. Thanks, again.

    -Michael
    Wednesday, December 16, 2009 10:02 PM
  • Hi Michael

    I don't think there is a way to accomplish what you are describing.

    The problem is that you can only place one instance of any programs executable file on the Taskbar. Since all of the shortcuts point to the same executable the Taskbar is seeing this as pinning the same program multiple times.

    The solution is to create a folder, place all of the cmd shortcuts into the folder and then use the Toolbars/New Toolbar to place that folder on the Taskbar. Give the new toolbar a short name so that it does not take up too much space.

    If you have Windows Explorer pinned to the Taskbar you could also simply pin the folder with the command prompt shortcuts to that Taskbar item.

    Hope this helps, and let us know if you find a tweak for an alternate way to accomplish this.

    Regards,


    Thank You for using Windows 7

    Ronnie Vernon MVP
    Wednesday, December 16, 2009 11:29 PM
  • While this does not answer your wish to pin to taskbar, may give some leads to belay, forestall insanity: into MyCmd.bat  I put
    %windir%\system32\cmd.exe /k color 3
    %windir%\system32\cmd.exe /k color 5

    When in 3 color, entry of "exit" takes it to 5 color etc.

    I put shortcut to MyCmd.bat into MyToolbar folder & so see icon on bottom right of taskbar

    Possibly what you wish to be doing could be simplified by or combined with scripting  
    http://technet.microsoft.com/en-us/scriptcenter/default.aspx
    http://social.technet.microsoft.com/Forums/en/ITCG/threads/

    You might see similar in forums, post your own. I was directed there in wish to auto
    do prtscr to picture.

    This is PasteScr.vbs that I got from forum, for example. After PrtScr keyboard button, this executed from MyToolbar shortcut takes clipboard through Paint to PictureN.jpg onto desktop.
    ________________________________________________________________________
    delay = 300
    paintWindowTitle = "untitled - Paint"

    set shl = createObject("wscript.Shell")
    set fso = CreateObject("Scripting.fileSystemObject")
    desktopFolder = shl.specialFolders("desktop")
    if right(desktopFolder, 1) <> "\" then
      desktopFolder = desktopFolder & "\"
    end if

    i = 1
    do
      filePath = desktopFolder & "Picture" & i & ".jpg"
      if not fso.fileExists(filePath) then exit do
      i = i + 1
    loop

    shl.run "mspaint"
    wscript.sleep delay
    shl.appActivate paintWindowTitle
    wscript.sleep delay
    shl.sendKeys "^v"
    wscript.sleep delay
    shl.sendKeys "^s"
    wscript.sleep delay
    shl.sendKeys filePath
    wscript.sleep delay
    shl.sendKeys "%s"
    wscript.sleep delay
    shl.sendKeys "%{f4}"
    ___________________________________________________________________

    Command variables:
    Microsoft Windows [Version 6.1.7100]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

    You can give options with CMD invoke 
    C:\Users\aB>cmd /?
    Starts a new instance of the Windows command interpreter

    CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
        [[/S] [/C | /K] string]

    /C      Carries out the command specified by string and then terminates
    /K      Carries out the command specified by string but remains
    /S      Modifies the treatment of string after /C or /K (see below)
    /Q      Turns echo off
    /D      Disable execution of AutoRun commands from registry (see below)
    /A      Causes the output of internal commands to a pipe or file to be ANSI
    /U      Causes the output of internal commands to a pipe or file to be
            Unicode
    /T:fg   Sets the foreground/background colors (see COLOR /? for more info)
    /E:ON   Enable command extensions (see below)
    /E:OFF  Disable command extensions (see below)
    /F:ON   Enable file and directory name completion characters (see below)
    /F:OFF  Disable file and directory name completion characters (see below)
    /V:ON   Enable delayed environment variable expansion using ! as the
            delimiter. For example, /V:ON would allow !var! to expand the
            variable var at execution time.  The var syntax expands variables
            at input time, which is quite a different thing when inside of a FOR
            loop.
    Press any key to continue . . .

    Thursday, December 17, 2009 11:58 AM
  • I don't think there is a way to accomplish what you are describing.

    The problem is that you can only place one instance of any programs executable file on the Taskbar. Since all of the shortcuts point to the same executable the Taskbar is seeing this as pinning the same program multiple times.
    Ron,

    That's too bad - but thanks for the information, nonetheless. I'll revert to using a Quick Launch style tool bar for now. I'll post a solution if I happen to come across one in my journey.

    This may become a non-issue by next June, anyway; this particular machine is running Windows 7 RC1. This computer is a small office file server, and originally ran Vista Business. With that OS, the clients (XP, Vista, Linux) couldn't stay connected to shared drives for more than a few hours at a time. In desperation, I upgraded to Windows 7 RC1 as soon as it was available. Now, I can last as long as 1-5 days before re-starting the 'Server' service (or, sometimes, rebooting)! While this is a dramatic improvement, it is still exceedingly painful.

    Unfortunately, I do not have a Windows 7 Ultimate license for this computer. I do have a Windows 7 Professional license to replace the original Windows Vista Business license. But, RC1 only came in the Ultimate flavor and, apparently, there's no way to downgrade from RC1 (Ultimate) to RTM Professional. If I'm going to need to re-install the OS by June anyway, I doubt I'll be putting Windows back on there - unless some intervening service pack / patch / hotfix cures my shared drive woes.

    Thanks for your help.

    -Michael
    Thursday, December 17, 2009 3:29 PM
  • TheGonzoIsIn,

    I hadn't considered using WSH to script a solution. It's a lot of work to replace a solution that was literally drag-and-drop in XP, but it might work. I can't promise that I'll invest the necessary effort to try it out right now, but if I get sufficiently frustrated with the existing UI I may give this a shot.

    Thank you for the idea.

    -Michael
    Thursday, December 17, 2009 3:37 PM
  • I found a neat way.

    Since the limitation is that the TaskBar won't allow more than one instance of the same executable to be pinned to the taskbar, our task is to convince Windows 7 that we're pinning different executables, when in fact we're starting C:\WINDOWS\SYSTEM32\CMD.EXE in every case.

    The way to do this is with a "reparse point" or "junction".  http://en.wikipedia.org/wiki/NTFS  (look down the page for "Reparse points")

    Sysinternals has published a tool called JUNCTION that exposes little-known functionality in NTFS that will allow you to create what Unix users might call a "link" to a file or folder.  You can find the software here: 

    http://technet.microsoft.com/en-us/sysinternals/bb896768.aspx

    Basically, you can make reparse points that look like two different folders but which really point to the same place.  For the sake of argument call them C:\TEMP\SYSTEM32_1 and C:\TEMP\SYSTEM32_2.  I'm using C:\TEMP for testing, but you'll probably want to put these a folder somewhere safe, that's not going to get deleted, perhaps under your user area.  The commands for this are:

    JUNCTION  C:\TEMP\SYSTEM32_1  C:\WINDOWS\SYSTEM32

    JUNCTION  C:\TEMP\SYSTEM32_2  C:\WINDOWS\SYSTEM32

    Now you can make shortcuts to what the OS considers two separate executables (C:\TEMP\SYSTEM32_1\CMD.EXE and C:\TEMP\SYSTEM32_2\CMD.EXE) give them their own settings, and happily pin them to the task bar.  Best of all, both of these run the one and only CMD.EXE in the system folder.

    Enjoy!

    -Noel

    Thursday, December 17, 2009 8:19 PM
  • Bump.  Hoping the OP will see this solution.

    -Noel

    Saturday, December 19, 2009 11:47 PM
  • Noel,

    This is a great idea; it sufficiently dupes the task bar into allowing multiple instances of the same executable, while physically maintaining only a single copy of cmd.exe for patching, storage space, etc. Nice work.

    If you'll indulge me yet a little more, I'm going to look the gift horse straight in the mouth and see if there is a way to take this one step further, in the interest of being tidy.

    I love the JUNCTION idea, but I'd like to limit the link to just the cmd.exe file, itself, as opposed to the whole system32 directory. Based on your suggestion, I tried creating a hard link using the MKLINK command. For example:

    mklink /h c:\windows\system32\yellow.exe c:\windows\system32\cmd.exe

    Unfortunately, this specific command yields an 'Access is denied.' error, even though I am a member of the Administrators group and the Command Prompt within which I'm running the MKLINK command was started with the 'Run as Administrator' option. I haven't found a lot of details online about use cases for MKLINK; just the command syntax, and a few stray comments.

    As a test, I copied cmd.exe up to the C:\ directory, and tried each combination of creating the link (yellow.exe) and referencing the target (cmd.exe) in the C:\ and C:\windows\system32 locations. The results are:

    C:\>mklink /h c:\windows\system32\yellow.exe c:\windows\system32\cmd.exe
    
    
    
    Access is denied.

    C:\>mklink /h c:\yellow.exe c:\windows\system32\cmd.exe
    Access is denied.

    C:\>mklink /h c:\windows\system32\yellow.exe c:\cmd.exe
    Hardlink created for c:\windows\system32\yellow.exe <<===>> c:\cmd.exe

    C:\>mklink /h c:\yellow.exe c:\cmd.exe
    Hardlink created for c:\yellow.exe <<===>> c:\cmd.exe

    Other executables from system32 behave the same way. So, it appears that the location of the target (cmd.exe) determines whether or not I can create a hard link.

    I don't understand why. ATTRIB shows that it only has the archive attribute set. I also reviewed the NTFS permissions on the file (cmd.exe) and its parent directory (system32). I won't include all of those details here (anyone can look them up on their own Windows 7 machine), but nothing jumps out at me as something that would prevent me from creating a new hard link.

    Q: Can anyone explain why MKLINK cannot make a hard link to an executable inside the %SystemRoot%\system32 directory?

    I'll keep fiddling with this to see if I can work out an answer. In the mean time, I'd appreciate the insight of anyone who has some more experience with / better understanding of the MKLINK command. Thanks, again, Noel, for your input.

    -Michael

    Sunday, December 20, 2009 5:16 PM
  • Sorry, all, for the terrible formatting in the post above. Things looked better in the editor when I was writing it, but the spacing and fonts appear to be hosed now that it's posted.
    Sunday, December 20, 2009 5:19 PM
  • I hadn't known about the MKLINK command.  Sounds like JUNCTION by another name, and is already supplied by the system.  I've never looked for a substitute for JUNCTION after having found it years ago.  Thanks for that.

    I found that the JUNCTION command would not allow me to make a file connection either.  Hence my suggestion to do it via a folder link.

    Perhaps the limitation is an exception programmed into the system to block some security hole found once by someone.  That's pure speculation.

    -Noel

    Sunday, December 20, 2009 5:28 PM
  • Hi Noel

    Sorry for the late reply, that last forum software update messed up the Alerts, again.

    This is a brilliant idea and one I didn't even think about.

    I agree with Michael that a Hard Link using mklink will probably work better with a file object.

    Michael

    When working with system files like this you are always going to be running into issues because of the heavy security on those system locations, such as permissions, ACL's, mandatory integrity levels, trusted installer issues and etc. 

    You have already found the best solution for a tweak such as this which is to simply copy the target system file to a different location, although the best location would be in a folder somewhere under the users folders heirarchy which will also work to bypass all of the security issues while still maintaining the security integrity of the system location.

    With a copy of cmd.exe in a sub-folder that you create under your username folder, you could then use mklink to create the new hard links in that same folder and then pin those hard links to the Taskbar.

    eg: C:\Users\username\TEST>mklink /h yellow.exe cmd.exe

    Have fun.

    Thank You for using Windows 7


    Ronnie Vernon MVP

    Sunday, December 20, 2009 9:00 PM
  • Thank you Ronnie, that was nice of you to say.  :)

    >that last forum software update messed up the Alerts, again

    Yes, I noticed the recent Activities list isn't updating.

    -Noel
    Sunday, December 20, 2009 9:41 PM
  • Manniongeo, I don't know why mklink.exe won't work in System32.  It didn't work for me either.  WFP at work, I guess.  I was able to do it with ln.exe on a Server 2008 on which I had Subsystem for UNIX-based applications enabled.  Not only did it work, it worked so well that the link also came under WFP.  When I tried to delete the new yellow.exe, I got Access is denied.  Go figure.

    Noel, mklink appeared in Vista and Server 2008.  It supports creating hard and symbolic links in addition to junctions.  Although, I am still not clear what the difference between junctions and symbolic links is, other than that you can create true relative symbolic links with mklink.

    Before Junction.exe was published by WinInternals (before it was part of Microsoft), there was a resource kit utility, linkd.exe.  As you may expect from the name, it only worked on directories, and only junctions.

    There were always POSIX utilities available, since POSIX compatibility was one of the original design requirements of Windows NT.  POSIX requires that the file system support hard links.

    History from a different millenium.
    Sunday, December 20, 2009 10:44 PM
  • @Ronnie
    >>eg: C:\Users\username\TEST>mklink /h yellow.exe cmd.exe

    In theory this seems like it would be the best solution but has anybody actually executed the new link without error?  Yes, a command prompt window will open but immediately before the command prompt in the window that is opened an error is thrown.  I receive the following error when setting up the hardlink and attempting to use it:
    The system cannot find message text for message number 0x2350 in the message file for Application.
    And if I create a symbolic link and execute that on the copy of cmd.exe I receive an error alert window rather than getting to the command prompt.  The error states:
    C:\Users\username\TEST\yellow.exe
    The specified path does not exist.
    
    Check the path, and then try again.
    Even so, if we could eliminate the errors this solution is not ideal as color coding options are not present in the properties tab for the linked resource.  Shortcuts allow the color variations but that puts us back in the same boat we started.

    I use my control interfaces in much the same fashion as manniongeo and certainly do miss the ease of quick launching the color-coded command line interface.  I've collected shortcuts in a folder and added a custom Taskbar Toolbar for now too.  Not as easy as it once once though, efficiency is hindered.
    Thursday, January 21, 2010 12:27 AM
  • In my case it just sufficed to provide a different command line in the "Target" field of the Shortcut property, i.e. instead of the standard:
     %windir%\system32\cmd.exe
    I just used:
     %windir%\system32\cmd.exe /t:07
    After doing that the according link could be dragged to the taskbar.

    Friday, March 25, 2011 9:49 PM
  • Hello, I didn't read the whole thread so this suggestion may already be there or not work for you.

    I tried the reparse thing, didn't work.  So I just copied cmd.exe to cmd1.exe.  You can do that as many times as you want and pin them all to the task bar.

    Friday, February 10, 2012 2:56 PM
  • Hi Ericdukece

    This is an older thread, but still good information.

    Thanks for posting.

    Regards


    Ronnie Vernon MVP – Windows Expert - Consumer

    Friday, February 10, 2012 7:49 PM
  • So I just copied cmd.exe to cmd1.exe.  You can do that as many times as you want and pin them all to the task bar.

    Just keep in mind one thing:  Don't expect Windows Update to apply any patches to them, should any be released.

    -Noel


    Detailed how-to in my new eBook: Configure The Windows 7 "To Work" Options

    Friday, February 10, 2012 10:14 PM
  • This is the solution that works perfectly.

     Very similar to an.re's solution...except using /t:07 was messing me up because it was resetting the color each time to black.   So I tried tweaking that to use a fake parameter, and it worked perfectly.  Here's how:

    Simply create shortcuts on your desktop pointing to the cmd.exe as follows using a fake /Z parameter:

     %windir%\system32\cmd.exe /Z:1
     %windir%\system32\cmd.exe /Z:2

     %windir%\system32\cmd.exe /Z:3

    etc

    Name them Green, Blue, Red, etc.

    Pin them individually to the Taskbar.

    Fire up each one, and set the colors and settings accordingly.

    Delete the shortcuts from the desktop.  And now you will have 3 separate shortcuts to the same cmd.exe executable in your taskbar.   The /Z: gets completely ignored.

    Thursday, August 22, 2013 1:43 PM