Microsoft Windows 2000
Server Administrator's Companion

by Sharon Crawford & Charlie Russel
copyright (c) 2000 by Microsoft Corporation
all rights reserved


Home
Articles
Utilities
Software

Electronic Book

Setting a UNC Path as the Current Directory

Since you can't execute a Change Directory to a UNC name in a command window, perform the following:

pushd \\server_name\share_name\other_path

This creates a temporary mapped drive to \\server_name\share_name, changes the current drive to \other_path.  Popd unmaps the drive.

Here's an extension of this idea. Take the Command Prompt Here power toy and modify it to work with UNC paths.

Go to the registry key:

HKEY_CLASSES_ROOT\Directory\shell\DosHere\command

and change the cd to pushd. You still get a message about not being able to set a UNC path as the current directory, but the pushd part maps the temporary drive and sets it as current!

If you enter pushd \\server\share  at the command line, it will automount the share as a drive, and makes the share the current drive.  Popd autodismounts the share drive and returns you to the starting drive.

For Example: If you start at C:, and Z: is the share drive:

pushd \\server_name\netlogon

 

    mounts the UNC path as Z: and the prompt becomes Z:>

popd

 

    returns you to C: and removes the Z: drive mapping.