"Slashes" in Vista/Windows Server 2008

OK, I knew that I could use "/" in PowerShell just about anywhere that Windows CMD wanted "\" - PowerShell is smart enough to figure out what I mean in almost every case. So:

PSH> cd c:/temp

works exactly the same as:

PSH> cd c:\temp

This works the same for executing commands and in PS1 scripts, making life easier for those of us who learned our scripting (and our command lines) at the Korn (or Bourne or bash or even C) shell prompt. And, I might add, this works in every version of PowerShell.

What's new, however, is that forward slashes now work in plain old Windows CMD windows. Yup, on my Vista SP1, and my Server 2008 boxes both. Open a "DOS" window (really cmd.exe) and try it.

C:\Users\Charlie> cd /

C:\> cd /d D:/download/PowerShell

D:\download\PowerShell>

Hunh. Who knew? Nice addition, Microsoft. Combine that with the support for symlinks and you've almost got something useful. But really, I'll stick to my PowerShell window 99% of all command line work. Really the only time I need a CMD window is when haven't yet been able to install Posh yet.

Charlie.

Published Sat, Jun 21 2008 22:16 by Charlie Russel

Comments

# Windows Vista News » "Slashes" in Vista/Windows Server 2008

Pingback from  Windows Vista News  » "Slashes" in Vista/Windows Server 2008

Friday, September 12, 2008 4:21 AM by Exotic Hadron

# re: "Slashes" in Vista/Windows Server 2008

Yeah, that's interesting. Now you can just type

C:\>cd /d d:/program files/

and it will work.

However, you'll miss automatic searching though the directory using TAB. I mean if you type

C:\>cd d:/Pro and press TAB you will get your CMD walking though the root dir - C:\ That is it pressing TAB will substitute folders in C:\ and you'll get something like

C:\>cd d:/"Program Files (x86)"

(and all other folders starting with pro but located on C:\ drive)

Quite the contrary, if you type

C:\>cd d:\Pro and press TAB you'll get

C:\>cd "d:\Products"

if you have this folder on D:\ drive

What's more, typing / as you know worked in NT 5.x too. Say typing

D:\>cd /SUPPORT\TOOLS

could get you the TOOLS on Windows Setup disc.