我的目标是将特定的注册表程序设置(例如 CCleaner)导入到活动系统的默认用户配置文件中,以确保新用户获得预定义的配置。我不想创建新的安装映像或使用任何商业第三方软件。
以下是将 .reg 文件导入另一个用户的配置文件的方法:
runas /u:User "cmd.exe /k reg import C:\Test.reg"
我将其改编为:
runas /u:DefaultAccount "cmd.exe /k reg import C:\Test.reg"
错误:
1327:登录失败:用户帐户限制。可能的原因是不允许使用空白密码、登录时间限制或强制执行策略限制。
因此我将以下注册表值更改为:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"LimitBlankPasswordUse"=dword:00000000
但尽管它与任何其他用户一起工作,但仍然会出现同样的错误!
那么如何通过命令行将 .reg 文件导入默认用户配置文件?
答案1
您需要先挂载 DEFAULT 用户配置文件:
reg load HKLM\DEFAULT c:\users\default\ntuser.dat
然后,您可以将设置导入或添加到新创建的 HKLM\DEFAULT 分支:(路径中reg add
没有尾随斜杠非常重要\
)
REM Advertising ID disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f
在您的情况下,您也可以导入 .reg 文件 - 但您需要确保编辑 .reg 以便路径适合您的挂载点:
regedit /s \\test.local\dfs\public\Deployment\Scripts\SetDefaults\Fix_An_app_default_was_reset_HKDU.reg
完成后,卸载 DEFAULT 注册表配置单元:
reg unload HKLM\DEFAULT
这是一个完整脚本的示例,我使用它来自定义新镜像的 Windows 10 计算机,现在“CopyProfile”unattend.xml 设置不再可靠地工作。我将其与其他脚本以及 Windows 10 配置包结合使用。
@ECHO OFF
REM This script configured the DEFAULT user profile for all new users on the system
reg load HKLM\DEFAULT c:\users\default\ntuser.dat
REM Advertising ID disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo" /v Enabled /t REG_DWORD /d 0 /f
REM Enable SmartScreen
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\AppHost" /v EnableWebContentEvaluation /t REG_DWORD /d 1 /f
REM Delivery optimization, disabled
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" /v SystemSettingsDownloadMode /t REG_DWORD /d 3 /f
REM Do not hide system tray icons
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer" /v EnableAutoTray /t REG_DWORD /d 0 /f
REM Show known file extensions
reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v HideFileExt /t REG_DWORD /d 0 /f
REM Remove search bar and only show
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" /v SearchboxTaskbarMode /t REG_DWORD /d 1 /f
REM Disable Game DVR
reg add "HKLM\DEFAULT\System\GameConfigStore" /v GameDVR_Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\GameDVR" /v AppCaptureEnabled /t REG_DWORD /d 0 /f
REM Set Desktop Background
mkdir %SystemRoot%\Web\Wallpaper\TEST
xcopy \\test.local\dfs\public\deployment\Customizations\TEST_Background_HiRes.png %SystemRoot%\Web\Wallpaper\TEST /Q /Y
xcopy \\test.local\dfs\public\deployment\Customizations\test.theme %SystemRoot%\Resources\Themes /Q /Y
REM reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes" /v InstallTheme /t REG_SZ /d "C:\Windows\resources\Themes\test.theme" /f
reg add "HKLM\DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Personalization" /v ThemeFile /t REG_SZ /d "C:\Windows\resources\Themes\test.theme" /f
REM Set Start Menu folders
REM reg add "HKLM\DEFAULT\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\$$windows.data.unifiedtile.startglobalproperties\Current" /v Data /t REG_BINARY /d 02000000bf6447b3e68ad3010000000043420100cb320a07058691cc930524aaa30144c38401669ff79db187cbd1acd4010005bcc9a8a401248cac034489850166a081bacbbdd7a8a482010005ceabd3e90224daf40344c38a016682e58bb1aefdfdbb3c0005afe69e9b0e24de930244d5860166bf9d879bbf8fc6d4370005a08cac800b24d1fe0144b2980166aabdd0e1cceadfb9150005a08ffcc103248ad0034480990166b0b599dccdb097de4d0005c5cbce95042486fb0144f485016680c9ced4afd99ec4b50100c23c0100 /f
REM Fix App Default Reset Warning
regedit /s \\test.local\dfs\public\Deployment\Scripts\SetDefaults\Fix_An_app_default_was_reset_HKDU.reg
REM Disable suggesting apps in start
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SystemPaneSuggestionsEnabled /t REG_DWORD /d 0 /f
REM Disable VMWare Tools tray icon
reg add "HKLM\DEFAULT\SOFTWARE\VMWare, Inc.\VMWare Tools" /v ShowTray /t REG_DWORD /d 0 /f
REM Set Google as default search provider in IE
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes" /v DefaultScope /t REG_SZ /d {e913ede7-630e-4d2a-a6af-2b28e7ce735b} /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v DisplayName /t REG_SZ /d Google /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v FaviconURL /t REG_SZ /d https://www.google.com/favicon.ico /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v ShowSearchSuggestions /t REG_DWORD /d 1 /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v SuggestionsURL /t REG_SZ /d "https://www.google.com/complete/search?q={searchTerms}&client=ie8&mw={ie:maxWidth}&sh={ie:sectionHeight}&rh={ie:rowHeight}&inputencoding={inputEncoding}&outputencoding={outputEncoding}" /f
reg add "HKLM\DEFAULT\SOFTWARE\Microsoft\Internet Explorer\SearchScopes\{e913ede7-630e-4d2a-a6af-2b28e7ce735b}" /v URL /t REG_SZ /d "https://www.google.com/search?q={searchTerms}&sourceid=ie7&rls=com.microsoft:{language}:{referrer:source}&ie={inputEncoding?}&oe={outputEncoding?}" /f
REM Finished
reg unload HKLM\DEFAULT