Windows Server 2016 桌面环境的自动配置脚本

时间:2022-02-21 02:18:58

除非学习要求,还是建议使用Windows 10 LTSB 2016或其他桌面系统。

github:https://github.com/m2nlight/WindowsServerToWindowsDesktop

它的功能是自动启动音频服务、允许未登录关机、禁用Ctrl+Alt+Del登录系统、禁用关机时要求输入关机原因、CPU性能优秀程序、IE安全策略、登录时不现实服务器管理器、禁用密码混淆和长度要求、当前用户密码永不过期,安装Bitlocker、Direct-Play、无线网络、优质Windows音视频体验组件。

将脚本复制到桌面,并且要求管理员权限,去运行,,输入y开始配置,会重新启动一次系统,演示效果如图:

脚本如下:

1 @echo off 2 pushd %~dp0 3 set gpfile=temp_gpfile 4 set currentuser=%username% 5 if "%currentuser%" == "" set currentuser=Administrator 6 echo Windows Server To Windows Desktop 7 echo ================================= 8 PowerShell /Command "&{Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption}" 9 echo Current Domain: %USERDOMAIN% 10 echo Current User: %currentuser% 11 echo. 12 set /p tmpInput=Maybe will restart computer. Are you ready? (Y/N): 13 if "%tmpInput%"=="y" goto :START 14 if "%tmpInput%"=="Y" goto :START 15 echo Canelled. 16 echo Press any key to exit... 17 pause>nul 18 goto :END 19 :START 20 echo (1/3) Config Service 21 echo - Automatic Audio Server 22 PowerShell /Command "&{Import-Module ServerManager}" 23 PowerShell /Command "&{Set-Service "Audiosrv" -StartupType Automatic}" 24 echo (2/3) Config Registry and GroupPolicy 25 echo - Shutdown without logon 26 REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ShutdownWithoutLogon /t REG_DWORD /d 1 /f>nul 27 echo - Disable Ctrl+Alt+Del 28 REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v DisableCAD /t REG_DWORD /d 1 /f>nul 29 echo - Disable Shutdown reason On 30 REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" /v ShutdownReasonOn /t REG_DWORD /d 0 /f>nul 31 echo - CPU Priority for Program 32 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl /v Win32PrioritySeparation /t REG_DWORD /d 38 /f>nul 33 echo - IE Security Policy 34 REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 0 /f>nul 35 REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 0 /f>nul 36 Rundll32 iesetup.dll, IEHardenLMSettings 37 Rundll32 iesetup.dll, IEHardenUser 38 Rundll32 iesetup.dll, IEHardenAdmin 39 echo - No autorun Server Manager 40 REG ADD HKLM\Software\Microsoft\ServerManager /v DoNotOpenServerManagerAtLogon /t REG_DWORD /d 1 /f>nul 41 echo - Disable Password complexity and Minimum password length 42 echo [version]>%gpfile%.inf 43 echo signature="$CHICAGO$">>%gpfile%.inf 44 echo [System Access]>>%gpfile%.inf 45 echo MinimumPasswordLength = 0 >>%gpfile%.inf 46 echo PasswordComplexity = 0 >>%gpfile%.inf 47 secedit /configure /db %gpfile%.sdb /cfg %gpfile%.inf /log %gpfile%.log>nul 2>nul 48 del %gpfile%.inf %gpfile%.sdb %gpfile%.log %gpfile%.jfm /f /q 49 echo - %currentuser%‘s Password nerver expires 50 wmic Path Win32_UserAccount Where Set PasswordExpires="FALSE">nul 51 echo PasswordExpires List: 52 wmic useraccount get Name,PasswordExpires 53 echo (3/3) Config Windows Feature 54 echo - BitLocker 55 echo - Direct-Play 56 echo - Wireless-Networking 57 echo - qWave 58 echo please wait... 59 PowerShell /Command "&{Install-WindowsFeature "BitLocker","Direct-Play","Wireless-Networking","qWave" -Restart}" 60 echo Completed! 61 echo Press any key to exit... 62 pause>nul 63 :END 64 popd

其他的手动配置:见github的readme。

Windows Server 2016 桌面环境的自动配置脚本