我对 Windows 7 x64 ISO 安装完成后编写的脚本感到疑惑。该脚本 (bat) 包含以下内容:
@echo off
cd C:\Users\
RD /S /Q "C:\Users\Public\"
cd C:\Users\Unknown\
ATTRIB +H "C:\Users\Unknown\Desktop"
RD /S /Q "C:\Users\Unknown\Searches"
RD /S /Q "C:\Users\Unknown\Saved Games"
RD /S /Q "C:\Users\Unknown\Videos"
RD /S /Q "C:\Users\Unknown\Links"
RD /S /Q "C:\Users\Unknown\Favorites"
RD /S /Q "C:\Users\Unknown\Contacts"
cd C:\
RD /S /Q "C:\PerfLogs\"
RD /S /Q "C:\Program Files\Uninstall Information"
RD /S /Q "C:\Program Files\Windows Media Player"
ATTRIB +H "C:\Program Files\Common Files" /S /D
ATTRIB +H "C:\Program Files\DVD Maker" /S /D
ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files\MSBuild" /S /D
ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files\Windows Defender" /S /D
ATTRIB +H "C:\Program Files\Windows Mail" /S /D
ATTRIB +H "C:\Program Files\Windows NT" /S /D
ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D
cd C:\Program Files (x86)\
RD /S /Q "C:\Program Files (x86)\Uninstall Information"
ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D
cd C:\ProgramData\Microsoft\Windows\Start Menu\
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"
cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"
C:\Windows\
RD /S /Q "C:\Windows\Downloaded Program Files"
RD /S /Q "C:\Windows\LiveKernelReports"
RD /S /Q "C:\Windows\Logs"
RD /S /Q "C:\Windows\ModemLogs"
RD /S /Q "C:\Windows\Offline Web Pages"
RD /S /Q "C:\Windows\Temp"
RD /S /Q "C:\Windows\WinToolkit"
cd C:\ProgramData\Microsoft\User Account Pictures\
REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"
Win7 安装完成后,我该如何植入这个脚本。尝试使用 SetupComplete(见剧透):
\sources\$OEM$\$$\Setup\Scripts
@ECHO OFF
cd %~dp0
attrib -R -A -S -H *.*
SHUTDOWN /R /T 5
RMDIR /S /Q "%WINDIR%\Setup\Scripts"
@echo off
cd C:\Users\
RD /S /Q "C:\Users\Public\"
cd C:\Users\Unknown\
ATTRIB +H "C:\Users\Unknown\Desktop"
RD /S /Q "C:\Users\Unknown\Searches"
RD /S /Q "C:\Users\Unknown\Saved Games"
RD /S /Q "C:\Users\Unknown\Videos"
RD /S /Q "C:\Users\Unknown\Links"
RD /S /Q "C:\Users\Unknown\Favorites"
RD /S /Q "C:\Users\Unknown\Contacts"
cd C:\
RD /S /Q "C:\PerfLogs\"
RD /S /Q "C:\Program Files\Uninstall Information"
RD /S /Q "C:\Program Files\Windows Media Player"
ATTRIB +H "C:\Program Files\Common Files" /S /D
ATTRIB +H "C:\Program Files\DVD Maker" /S /D
ATTRIB +H "C:\Program Files\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files\MSBuild" /S /D
ATTRIB +H "C:\Program Files\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files\Windows Defender" /S /D
ATTRIB +H "C:\Program Files\Windows Mail" /S /D
ATTRIB +H "C:\Program Files\Windows NT" /S /D
ATTRIB +H "C:\Program Files\Windows Photo Viewer" /S /D
cd C:\Program Files (x86)\
RD /S /Q "C:\Program Files (x86)\Uninstall Information"
ATTRIB +H "C:\Program Files (x86)\Common Files" /S /D
ATTRIB +H "C:\Program Files (x86)\Internet Explorer" /S /D
ATTRIB +H "C:\Program Files (x86)\MSBuild" /S /D
ATTRIB +H "C:\Program Files (x86)\Reference Assemblies" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Defender" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Mail" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows NT" /S /D
ATTRIB +H "C:\Program Files (x86)\Windows Photo Viewer" /S /D
cd C:\ProgramData\Microsoft\Windows\Start Menu\
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Maintenance"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Games"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Windows PowerShell"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
RD /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Default Programs.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Windows Update.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sync Center.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Sound Recorder.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Paint.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\displayswitch.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Calculator.lnk"
DEL /F /S /Q /A "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Welcome Center.lnk"
cd C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Maintenance\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools\"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Accessibility"
RD /S /Q "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\System Tools"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Windows Explorer.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Run.lnk"
DEL /F /S /Q /A "C:\Users\Unknown\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Accessories\Command Prompt.lnk"
C:\Windows\
RD /S /Q "C:\Windows\Downloaded Program Files"
RD /S /Q "C:\Windows\LiveKernelReports"
RD /S /Q "C:\Windows\Logs"
RD /S /Q "C:\Windows\ModemLogs"
RD /S /Q "C:\Windows\Offline Web Pages"
RD /S /Q "C:\Windows\Temp"
RD /S /Q "C:\Windows\WinToolkit"
cd C:\ProgramData\Microsoft\User Account Pictures\
REN "C:\ProgramData\Microsoft\User Account Pictures\user.bmp" "user.x"
REN "C:\ProgramData\Microsoft\User Account Pictures\guest.bmp" "guest.x"
问题是,我也不能使用 GPO,因为我更喜欢 Home Premium。
答案1
安装期间,Windows 安装盘不是 C:\,它可以作为任何驱动器安装,但通常映射到 X:\
在安装过程中访问安装分区的最佳方式是通过 %SystemDrive%\YOUR_PATH_HERE_FROM_ROOT
假设 \Users\Unknown 是尚未设置的用户帐户,它尚不存在。并且没有与用户帐户有关的名为 Unknown 的变量,如果您使用用户帐户 Unknown 创建了安装映像,那么只需从已安装的 WIM 中删除文件夹,然后基本上对您想要进行的更改进行硬编码,就会容易得多。
此外,考虑到开始菜单文件夹,您应该包含 \* 来删除其中的任何文件,然后在下一行删除文件夹本身。
此外,您不需要使用 %SystemRoot% 访问 Program Data 文件夹,您可以直接使用 %ProgramData% 访问它,以节省一些输入。
另外,你为什么在脚本的开头告诉计算机在 5 秒内关闭?为什么你甚至会冒险在它完成之前不完成所有事情?把它放在脚本的末尾,拜托兄弟。
这里有一些您急需的变量。
%ProgramData%、%SystemRoot%、%ProgramFiles%、%ProgramFiles(x86)%(%ProgramFiles(x86)% 依赖于您在 x64 模式下运行所有内容,如果是 x86,则 %ProgramFiles% 和 %ProgramFiles(x86)% 都将返回 \Program Files(x86),这很容易弄乱您的内容。)