surprises from windows

I’ve spent at least an hour tracking down an error in integration of my software with another software. Finally, I’ve found that Windows (ok, command chdir isn’t so easy. If one wants to go to a directory on another drive, the flag /D must be used, otherwise nothing happens. Did you know it?

9 Responses to “surprises from windows”

  1. M. David Peterson Says:

    Just typing the drive letter itself will immediately change the context drive to the specified drive letter. e.g. > D: + enter will change the context drive to D:\

    What’s nice about this is that it remembers your path location the last time (during that session) you visited that drive, so if you were @ D:\foo\bar\baz and typed C: you would arrive at the last location you were at on your C drive, and if you were to then type D: you would immediately find yourself back @ D:\foo\bar\baz

    It’s a nice way to navigate around multiple drives, especially network drives and folders that you visit often.

  2. olpa Says:

    Hello! I’m happy to see you in my blog!

    Remembering the path location on the drive — it’s definitely an useful trick. But who uses the command prompt now?

  3. M. David Peterson Says:

    I’m happy to be on your blog :D

    re: who uses the command prompt,

    I still use it extensively, but I doubt much I am a common use case. It seems most people who are command line-types on Windows have switched to Windows Power Shell. I actually use PowerShell as well, but tend to use the command prompt out of force of habit, especially for simple tasks. Of course, PowerShell supports the same syntax as cmd.exe as well as the extended and MUCH improved internal syntax, so either way its knowledge worth hanging on to.

    One thing I forgot to mention: You can also change the context of the drive path w/o actually switching to the drive. This, I believe, is the behavior you are noticing in your original post. So, for example,

    C:\> cd D:\foo\bar\baz

    would seem as if nothing has happened (which as you point out requires the /D switch to function as you might expect), but in fact what has happened is that you have changed pushed \foo\bar\baz to the top of the history stack for the D: drive. If after typing the above you were to then type D: + enter you would find yourself at D:\foo\bar\baz. This particular “trick” is helpful inside of scripts and what have you when you want to change the path context of a drive inside of a script using a dynamically generated path value (e.g. %HOMEPATH% ) w/o actually switching to that drive/directory until you have finished the work you are doing on the existing drive/directory. By then adding %HOMEDRIVE% to your script, you will switch to the drive in which the current users home directory exists and find yourself inside of the proper home directory automatically. You can quickly and easily switch back and forth between two or more drives throughout the remainder of your script by simply using the drive letter that you want to switch to.

    Of course one might wonder if this is really all that necessary and the answer in most cases is probably not. But it can be both a time and code saver in some cases, so its a trick worth keeping in mind for the cases in which is actually does provide value.

  4. olpa Says:

    Thanks, very interesting!

    But an old dog can’t learn new tricks. Among the first applications I install on Windows boxes are CygWin or minGW. As result, I can use bash or any other Unix shell. After them, working with cmd.exe (and probably PowerShell too (haven’t tried)) is just frustration.

  5. M. David Peterson Says:

    >> and probably PowerShell too (haven’t tried)) is just frustration.

    Alas, this is where it gets exciting :) PowerShell is both heavily inspired as well as heavily based on the Unix command line. Of course, not all of the commands you are used to having at your finger tips are available, but the ones that have a tendency to drive you insane (e.g. typing “ls” instead of “dir”) are all built directly into the core command set. And of course the one thing that always drives me to the point of insanity > that of remembering to use \ instead of / is no longer a concern either. PowerShell handles either, with full tab completion, so for all intents and purposes, the Windows command line has become usable from a cross-platform cross-over perspective.

  6. olpa Says:

    Thanks, I’ll give it a try. Time to time, I have Windows sessions where I can’t install cygwin/mingw, therefore PowerShell might be useful.

  7. olpa Says:

    Unfortunately, there is no PowerShell fro Windows 2000. Or I haven’t found it.

  8. M. David Peterson Says:

    > Unfortunately, there is no PowerShell fro Windows 2000. Or I haven’t found it.

    Ugg! Yeah, you’re right: They’re is no PowerShell for Win2k. That sucks!

  9. Barney Says:

    Actually, there is/was a PowerShell for Win2K. I keep finding Google cache references to it, even on MS download pages, yet when I visit the page, the correct download doesn’t exist.

    It’s highly frustrating that Microsoft deleted all references to it’s older downloads for Win 2k.

    Just another reason to S#!+ – CAN Windows and go to Linux (for me that move will be to Ubuntu on all of my computers) as soon as I’ve verified Ubuntu’s hardware support of my devices (internal and external)…

    MS (especially with the ridiculous price of Vista) has forced all non-millionaires to move to Linux… whether they realize it or not.

    My independent business will be focused on getting users who can’t afford Vista onto Ubuntu, as well as supporting their move to Ubuntu.

    Peace out,


Leave a Reply