以前在Windows(Windows)中创建过替代驱动器吗?如果没有,Windows中的(Windows)SUBST命令允许您将长文件路径(file path)映射到驱动器号。
例如,您可以使用此命令将存储在 C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\OutlookOutlook 文件夹(Outlook folder)映射到像Z这样的驱动器号。
每当您单击“我的电脑”中的(My Computer)Z 驱动器(Z drive)时,您实际上会被重定向到Outlook 文件夹(Outlook folder)!这在许多不同的情况下非常有用,尤其是在使用长度超过 256 个字符的路径时。
那么使用SUBST命令有什么问题呢?它不是持久的!这意味着当您重新启动计算机时,您的驱动器就消失了。您必须重新创建它,并且您不能让任何启动程序尝试(program try)访问替换的驱动器,因为它会消失。
psubst是一个漂亮的小程序,您可以使用它在Windows中创建永久替代驱动器,即使在重新启动后仍会保留。
使用psubst在(psubst)Windows中创建永久虚拟驱动器非常容易。首先(First),下载ZIP 存档(ZIP archive)并解压缩 .BAT 文件。您只需右键单击ZIP 文件并选择(ZIP file and choosing)Extract All即可在( Extract All)Windows中提取文件。

继续将psubst.bat文件放入您的C:\Windows\System32文件夹,以便您可以在命令提示符(command prompt)下的任何位置运行它。

到位后,转到命令提示符(command prompt)(Start、Run、CMD或只需在搜索框中键入(search box)CMD)并开始创建虚拟驱动器。使用 psubst 的语法如下:
创建磁盘:(Create a disk:)
psubst drive1: drive2:path
删除磁盘:(Delete a disk:)
psubst drive1: /D
现有磁盘列表:(List of existing disks:)
psubst
这将使用标准subst 命令(subst command)来创建虚拟驱动器。如果您想创建一个持久的,只需 /P 参数,如下所示:
创建永久虚拟驱动器:(Create a persistent virtual drive:)
psubst drive1: drive2:path /P
删除永久虚拟驱动器:(Delete a persistent virtual drive:)
psubst drive1: /D /P
因此,要为我上面提到的Outlook 数据(Outlook data)文件夹创建一个永久虚拟硬盘驱动器 (Z) ,我将发出以下命令:
psubst z: "C:\Documents and Settings\akishore\Local Settings\Application Data\Microsoft\Outlook" /P

现在您的新驱动器将在我的电脑(My Computer)中显示为本地磁盘:

单击磁盘将直接带入Outlook文件夹。如果您将文件或文件夹放在驱动器(drive letter)号上,数据将被复制到该文件夹中。
当您重新启动计算机时,您的驱动器仍然存在。不仅如此,您甚至可以在Windows完全启动之前让其他程序(例如服务等)访问虚拟驱动器,因为驱动器将可用。它还会显示在使用资源管理器(Explorer)的任何地方,例如打开(Open)对话框、另存为( Save as)对话框等。

总体而言,将文件夹映射到驱动器号是快速轻松地访问非常深的文件夹的好方法。您显然也可以为您的文件夹创建桌面快捷方式(desktop shortcut),但替代驱动器方法(drive method)的优点是可以从任何允许您浏览计算机的Windows 对话框中访问。(Windows dialog)如果您有任何问题,请随时发表评论。享受!
Map a Folder to a Drive Letter in Windows
Ever creatе a substituted drive in Windows before? If not, the SUBST command in Windows allows you to map a long file path to a drive letter.
For example, you could use this command to map the Outlook folder stored at C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Outlook to a drive letter like Z.
Whenever you click on the Z drive in My Computer, you would actually be redirected to the Outlook folder! This can be very useful in many different situations, especially when working with paths that are longer than 256 characters.
So what’s the problem with using the SUBST command? It’s not persistent! That means when you restart the computer, your drive is gone. You have to create it again and you can’t have any startup program try to access the substituted drive since it’ll disappear.
psubst is a nifty little program that you can use to create persistent substituted drive in Windows that will remain even after restarting.
Creating a persistent virtual drive in Windows using psubst is very easy. First, download the ZIP archive and extract the .BAT file. You can extract files in Windows by simply right-clicking on the ZIP file and choosing Extract All.

Go ahead and drop the psubst.bat file into your C:\Windows\System32 folder so that you can run it from anywhere at the command prompt.

Once in place, go to the command prompt (Start, Run, CMD or just type CMD into the search box) and start creating virtual drives. The syntax for using psubst is as follows:
Create a disk:
psubst drive1: drive2:path
Delete a disk:
psubst drive1: /D
List of existing disks:
psubst
This will use the standard subst command to create virtual drives. If you wan to create a persistent one, just the /P argument as shown:
Create a persistent virtual drive:
psubst drive1: drive2:path /P
Delete a persistent virtual drive:
psubst drive1: /D /P
So to create a persistent virtual hard drive (Z) to the Outlook data folder I mentioned above, I would issue the following command:
psubst z: "C:\Documents and Settings\akishore\Local Settings\Application Data\Microsoft\Outlook" /P

Now your new drive will show up as a local disk in My Computer:

Clicking on the disk will bring your directly into the Outlook folder. If you drop files or folders on the drive letter, the data will be copied to the folder.
When you restart your computer, your drive will still be there. Not only that, but you can have other programs, such as services, etc, access the virtual drive even before Windows fully starts up because the drive will be available. It also shows up anywhere that Explorer is used like Open dialogs, Save as dialogs, etc.

Overall, mapping a folder to a drive letter is a great way to access a very deep folder quickly and easily. You can obviously also create a desktop shortcut to your folder, but the substituted drive method has the advantage of being accessible from any Windows dialog that lets you browse the computer. If you have a any questions, feel free to comment. Enjoy!