详见http://blogs.msdn.com/b/heaths/archive/2014/02/11/how-to-relocate-the-package-cache.aspx
(注意:若Windows自动更新之后导致Windows installer文件路径找不到,可以在磁盘管理中,重新把installer的虚拟盘映射到C:Windows installer)
在CMD打开diskpart工具
diskpart
创建一个最大为16G空间的虚拟磁盘
create vdisk file="E:VHDCache.vhd" type=expandable maximum=16384
连接并创建分区
select vdisk file="E:VHDCache.vhd"
attach vdisk
create partition primary
格式化分区,卷名Package Cache,盘符P
format fs=ntfs label="Package Cache" quick
assign letter=P
exit
拷贝Package Cache到刚创建的虚拟磁盘P中
robocopy "%ProgramData%Package Cache" P: /e /copyall /move /zb
...等待.....
mkdir "%ProgramData%Package Cache"
echo y | cacls foo /s:"O:BAG:DUD:PAI(A;OICIID;FA;;;BA)(A;OICIID;FA;;;SY)(A;OICIID;FRFX;;;BU)(A;OICIID;FRFX;;;WD)"
查看P盘的GUID
mountvol
并将Package Cache目录指向
mountvol "%ProgramData%Package Cache" \?Volume{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
卸载盘符P
diskpart
select vdisk file="E:VHDCache.vhd"
select partition 1
remove letter=P
exit
开机自动挂载虚拟磁盘,并删除盘符
echo select vdisk file=E:VHDCache.vhd > E:VHDCache.txt
echo attach vdisk >> E:VHDCache.txt
schtasks /create /ru system /sc onstart /rl highest /tn "Attach Package Cache" /tr "%SystemRoot%System32diskpart.exe /s E:VHDCache.txt"
同以此方法,创建C:WindowsInstaller的虚拟磁盘
在CMD打开diskpart工具
diskpart
创建一个最大为16G空间的虚拟磁盘
create vdisk file="E:VHDInstaller.vhd" type=expandable maximum=16384
连接并创建分区
select vdisk file="E:VHDInstaller.vhd"
attach vdisk
create partition primary
格式化分区,卷名Package Cache,盘符Q
format fs=ntfs label="Installer" quick
assign letter=Q
exit
拷贝Package Cache到刚创建的虚拟磁盘Q中
robocopy "C:WindowsInstaller" Q: /e /copyall /move /zb
...等待.....
mkdir "C:WindowsInstaller"
echo y | cacls foo /s:"O:BAG:DUD:PAI(A;OICIID;FA;;;BA)(A;OICIID;FA;;;SY)(A;OICIID;FRFX;;;BU)(A;OICIID;FRFX;;;WD)"
查看P盘的GUID
mountvol
并将Installer目录指向
mountvol "C:WindowsInstaller" \?Volume{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
卸载盘符P
diskpart
select vdisk file="E:VHDInstaller.vhd"
select partition 1
remove letter=Q
exit
开机自动挂载虚拟磁盘,并删除盘符
echo select vdisk file=E:VHDInstaller.vhd > E:VHDInstaller.txt
echo attach vdisk >> E:VHDInstaller.txt
schtasks /create /ru system /sc onstart /rl highest /tn "Attach Installer" /tr "%SystemRoot%System32diskpart.exe /s E:VHDInstaller.txt"