【转】转移Package Cache文件夹,转移Windows Installer文件夹

时间:2023-03-08 17:42:33
【转】转移Package Cache文件夹,转移Windows Installer文件夹

详见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:\VHD\Cache.vhd" type=expandable maximum=16384

连接并创建分区

select vdisk file="E:\VHD\Cache.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:\VHD\Cache.vhd"

select partition 1

remove letter=P

exit

开机自动挂载虚拟磁盘,并删除盘符

echo select vdisk file=E:\VHD\Cache.vhd > E:\VHD\Cache.txt

echo attach vdisk >> E:\VHD\Cache.txt

schtasks /create /ru system /sc onstart /rl highest /tn "Attach Package Cache" /tr "%SystemRoot%\System32\diskpart.exe /s E:\VHD\Cache.txt"

同以此方法,创建C:\Windows\Installer的虚拟磁盘

在CMD打开diskpart工具

diskpart

创建一个最大为16G空间的虚拟磁盘

create vdisk file="E:\VHD\Installer.vhd" type=expandable maximum=16384

连接并创建分区

select vdisk file="E:\VHD\Installer.vhd"

attach vdisk

create partition primary

格式化分区,卷名Package Cache,盘符Q

format fs=ntfs label="Installer" quick

assign letter=Q

exit

拷贝Package Cache到刚创建的虚拟磁盘Q中

robocopy "C:\Windows\Installer" Q:\ /e /copyall /move /zb

...等待.....

mkdir "C:\Windows\Installer"

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:\Windows\Installer" \\?\Volume{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\

卸载盘符P

diskpart

select vdisk file="E:\VHD\Installer.vhd"

select partition 1

remove letter=Q

exit

开机自动挂载虚拟磁盘,并删除盘符

echo select vdisk file=E:\VHD\Installer.vhd > E:\VHD\Installer.txt

echo attach vdisk >> E:\VHD\Installer.txt

schtasks /create /ru system /sc onstart /rl highest /tn "Attach Installer" /tr "%SystemRoot%\System32\diskpart.exe /s E:\VHD\Installer.txt"