Skip to content

Instantly share code, notes, and snippets.

@muink
Last active May 4, 2024 01:16
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save muink/1f963c5229328c4f5da408076af13448 to your computer and use it in GitHub Desktop.
Save muink/1f963c5229328c4f5da408076af13448 to your computer and use it in GitHub Desktop.
普通系统切换为WTG的方法

Windows To Go 与 典型的 Windows 安装的区别

  • 本机磁碟不会自动联机
  • 没有WinRE环境

Windows To Go 的部署过程可以参考我前面的文章

除了以上两个区别,Windows To Go 与传统 Windows 系统的差别在于两个注册表键值BootDriverFlagsPortableOperatingSystem

  • BootDriverFlags 用于控制硬件启动顺序,让系统能在USB介面上启动的最重要的控制项
  • PortableOperatingSystem 用于控制系统是否允许进行更新

以下是一个将本机系统转换为Windows To Go系统的简单一键脚本

switch-to-WTG.bat

:: switch to WTG
:: switch to WTG
:: Author: muink


@echo off
%~1 mshta vbscript:createobject("shell.application").shellexecute("%~f0","::","","runas",1)(window.close)&exit

::设定USB启动
for /f "tokens=2* delims= " %%i in ('reg query HKLM\SYSTEM\HardwareConfig /v LastConfig 2^>nul^|findstr /i LastConfig') do set "guid=%%j"
reg add HKLM\SYSTEM\HardwareConfig\%guid% /v BootDriverFlags /t reg_dword /d 0x14 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control /v PortableOperatingSystem /t reg_dword /d 1 /f

::防止本机磁盘自动联机(保持脱机)
reg add HKLM\SYSTEM\CurrentControlSet\Services\partmgr\Parameters /v SanPolicy /t reg_dword /d 4 /f

*此脚本于Win10 1803系统测试通过

对于Windows 7/8 这些较老的系统,可以用传统的方式添加USB启动的支持,参阅我的另外一个工具


参考:
提交规则:切换系统WindowsToGo状态(方便安装更新)
【转载】控制Win8 Windows TO GO和USB启动的两个关键注册表项
控制Win8 Windows TO GO和USB启动的两个关键注册表项

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment