cmd - 可以临时将可用的驱动器号分配给本地路径吗? [英] cmd - Is it possible to temporarily assign an available drive letter to a local path?

查看:204
本文介绍了cmd - 可以临时将可用的驱动器号分配给本地路径吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上使用cmd,可以轻松地将驱动器号分配给带有pushd的UNC路径:

Using cmd on Windows, it is easy to assign a drive letter to a UNC path with pushd:

C:\Windows\> pushd \\server\share\path
Y:\> popd
C:\Windows\>

但是,我想使用本地路径因为它会缩短文件路径,我必须使用不支持具有很长路径的文件的命令。

However I would like to be able to do the same with local paths because it will shorten the file paths and I have to use commands that do not support files having a very long path.

这个想法是没有<$ c $

The idea is the following without the G: hardcoded in the script, because it could be used on another machine.

subst G: .
pushd G:\
(other commands)
popd
subst G: /d

我尝试过 pushd \\?\%CD% 但不幸的是它不起作用...

I have tried pushd \\?\%CD% but unfortunately it does not work…

谢谢

推荐答案

你在Windows 7你不必使用驱动器的信件。

If your'e on windows 7 you don't have to use drive letters. You can create a symbolic link instead.

要链接到文件夹,请使用:

To link to a folder use:

cd <folder_you_want_the_link_in>
mklink /D \MyLinkedFolder \Folder\Folder\Folder\Folder\MyLinkedFolder

这篇关于cmd - 可以临时将可用的驱动器号分配给本地路径吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆