2008年8月4日星期一

使用ntfs的连接点移动 document and setting

使用ntfs的连接点移动 document and setting
由于windows使用document and setting 存储了大量内容,单纯使用profile的方法不能够移走document and setting 目录,因为很多动态库在注册表中记录了document and setting 目录的绝对位置


2000,xp,2k3中的ntfs5多了一个新特性,就是连接点,可以象linux 下面那样
直接mount一个分区到一个ntfs5的目录上,也可以在ntfs5上生成一个目录或者文件的符号连接
这里有两个命令可以使用,一个是 mountvol (这个命令是windows 自带的),就是mount一个分区到一个ntfs的目录上,而且只能mount分区,

另一个命令是linkd.exe,是windows的资源工具箱中的,可以在微软下载
http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4ae7-96ee-b18c4790cffd&DisplayLang=en
这个命令可以把 ntfs分区上的 document and setting 目录 映射到另一个分区的某个目录。

使用 mountvol 的方法:
首先运行mountvol,获得需要mount的卷名称,如 代码:
--------------------------------------------------------------------------------
\\?\Volume{ef2c5830-890a-11d8-9112-806e6f6e6963}\
C:\
\\?\Volume{ef2c5831-890a-11d8-9112-806e6f6e6963}\
D:\
\\?\Volume{ef2c5832-890a-11d8-9112-806e6f6e6963}\
E:\
--------------------------------------------------------------------------------
假设系统在c盘,要把document and setting 目录移动到D盘
然后 写下如下的脚本 代码:
--------------------------------------------------------------------------------
xcopy "c:\document and setting" D:\ /S /E /H
ren "c:\document and setting" "c:\document and setting .bak"
md "c:\document and setting"
mountvol "c:\document and setting" \\?\Volume{ef2c5831-890a-11d8-9112-806e6f6e6963}\
--------------------------------------------------------------------------------
把如下的脚本放到开机脚本去运行,输入“gpedit.msc”后回车,打开组策略编辑器。依次展开“计算机管理→Windows设置→脚本(启动/关闭)”,双击启动项,然后添加,
然后重新启动,这样 你的"c:\document and setting" 就被定向到 D盘了
ps: 上面的开机脚本 只要执行一次,冲启动后,记住 删除该脚本。

使用 linkd.exe的方法:
优于mountvol的方面是: linkd 可以把"c:\document and setting" 目录 映射到d盘的某个目录,而不是d盘

linkd 的命令很简单 :用下面的命令替换前面脚本中 mountvol的部分就可以了,xcopy需要相应的修改,其他不变 代码:
--------------------------------------------------------------------------------
linkd "c:\document and setting" d:\xxxxxxxxx
--------------------------------------------------------------------------------

没有评论: