Windows Server 2016 桌面环境的自动配置脚本(2017-10-24更新)

本文介绍了一种将Windows Server转换为更接近桌面体验的方法,包括自动启动音频服务、禁用某些安全策略、调整视觉效果、优化网络设置及安装特定功能等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

form:https://www.cnblogs.com/Bob-wei/p/6055087.html

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

下载:https://github.com/m2nlight/WindowsServerToWindowsDesktop/archive/master.zip

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

 

  • Config Service

    • [Automatic] Windows Audio
    • [Automatic] Windows Audio Endpoint Builder
    • [Manual] Windows Remote Management (WS-Management)
  • Config Registry and GroupPolicy

    • Enable Shutdown without logon
    • Disable Shutdown reason On
    • No Lock Screen
    • Disable Ctrl+Alt+Del login
    • Disable UAC
    • Disable DEP (Turn on DEP for essential Windows programs and services only)
    • Disable SEHOP
    • Enable disk performance counters
    • Enable Video Hardware Acceleration (Thanks @cjrcl)
    • Enable Audio Hardware Acceleration
    • CPU Priority for Program
    • Adjust Visual Effects (Manual)
    • Adjust IE MaxConnection
    • IE Security Policy
    • Disable TCP Auto-Tuning
    • Change Power Scheme To High Performance
    • No Autorun Server Manager
    • Disable Password complexity and Minimum password length
    • Current user Password never expires
    • Disable Application Experience task schedulers
    • Disable Customer Experience Improvement Program task schedulers
  • Config Windows Feature

    • BitLocker
    • Direct-Play
    • Wireless-Networking
    • qWave


 

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

 

BAT脚本如下:

复制代码

  1 @echo off
  2 pushd %~dp0
  3 set gpfile=temp_gpfile
  4 set currentuser=%username%
  5 set videopsfile=Acceleration.Level.ps1
  6 rem UAC code begin
  7 set getadminfile=getadmin.vbs
  8 echo Windows Server To Windows Desktop
  9 echo =================================
 10 echo Starting
 11 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\SYSTEM" >nul 2>nul
 12 if %ERRORLEVEL% EQU 0 (
 13     goto :Admin
 14 ) else (
 15     if %ERRORLEVEL% EQU 2 (
 16         goto :PathErr
 17     ) else (
 18         goto :UAC
 19     )
 20 )
 21 :PathErr
 22 echo.
 23 echo Please open "%~n0%~x0" by explorer.exe
 24 echo.
 25 echo Press any key to explore the folder...
 26 pause>nul
 27 start "" "%SYSTEMROOT%\system32\explorer.exe" /select,"%~f0"
 28 goto :END
 29 :UAC
 30 echo Set sh = CreateObject^("Shell.Application"^) > %getadminfile%
 31 echo sh.ShellExecute "%~f0", "", "", "runas", 1 >> %getadminfile%
 32 ping 127.1 -n 1 >nul
 33 "%SYSTEMROOT%\system32\cscript.exe" %getadminfile%
 34 goto :END
 35 :Admin
 36 if exist %getadminfile% ( del %getadminfile% )
 37 cls
 38 rem UAC code end
 39 if "%currentuser%" == "" set currentuser=Administrator
 40 echo Windows Server To Windows Desktop
 41 echo =================================
 42 ::PowerShell /Command "&{Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption}"
 43 set caption=
 44 for /f "skip=1 delims=" %%t in ('wmic os get caption') do (
 45 if not defined caption set caption=%%t
 46 )
 47 echo %caption%
 48 echo %caption%|find /i "Windows Server">nul 2>nul
 49 if ERRORLEVEL 1 goto :OSERR
 50 echo Current Domain: %USERDOMAIN%
 51 echo Current User: %currentuser%
 52 echo.
 53 set /p tmpInput=Maybe will restart computer. Are you ready? (Y/N):
 54 if /i "%tmpInput%"=="y" goto :START
 55 echo Canelled.
 56 echo Press any key to exit...
 57 pause>nul
 58 goto :END
 59 :OSERR
 60 echo.
 61 echo ERROR: Unsupported operating system!
 62 echo Press any key to exit...
 63 pause>nul
 64 goto :END
 65 :START
 66 echo (1/3) Config Service
 67 PowerShell /Command "&{Import-Module ServerManager}"
 68 echo - [Automatic] Windows Audio
 69 PowerShell /Command "&{Set-Service "Audiosrv" -StartupType Automatic}"
 70 echo - [Automatic] Windows Audio Endpoint Builder
 71 PowerShell /Command "&{Set-Service "AudioEndpointBuilder" -StartupType Automatic}"
 72 echo - [Manual] Windows Remote Management (WS-Management)
 73 PowerShell /Command "&{Set-Service "WinRM" -StartupType Manual}"
 74 echo (2/3) Config Registry and GroupPolicy
 75 echo - Enable Shutdown without logon
 76 REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ShutdownWithoutLogon /t REG_DWORD /d 1 /f>nul
 77 echo - Disable Shutdown reason On
 78 REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" /v ShutdownReasonOn /t REG_DWORD /d 0 /f>nul
 79 :: echo - No Lock Screen
 80 :: reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Personalization" /v "NoLockScreen" /t REG_DWORD /d 0x1 /f>nul
 81 echo - Disable Ctrl+Alt+Del login
 82 REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v DisableCAD /t REG_DWORD /d 1 /f>nul
 83 echo - Disable UAC
 84 reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d 0x0 /f>nul
 85 echo - Disable DEP (Turn on DEP for essential Windows programs and services only)
 86 bcdedit /set {current} nx OptIn>nul
 87 ::bcdedit /set {current} nx AlwaysOff>nul
 88 echo - Disable SEHOP
 89 reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\kernel" /v "DisableExceptionChainValidation" /t REG_DWORD /d 0x1 /f>nul
 90 echo - Enable disk performance counters
 91 diskperf -Y>nul
 92 if exist %videopsfile%. (
 93 echo - Enable Video Hardware Acceleration
 94 PowerShell -ExecutionPolicy Unrestricted -File %videopsfile%>nul
 95 del Acceleration.Level.reg /f /q
 96 )
 97 echo - Enable Audio Hardware Acceleration
 98 reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" /v "SystemResponsiveness" /t REG_DWORD /d 0x14 /f>nul
 99 echo - CPU Priority for Program
100 REG ADD HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl /v Win32PrioritySeparation /t REG_DWORD /d 38 /f>nul
101 echo - Adjust Visual Effects (Manual)
102 SystemPropertiesPerformance.exe
103 ::reg add HKU\.DEFAULT\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects /v VisualFXSetting /t REG_DWORD /d 1 /f>nul
104 ::reg add HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects /v VisualFXSetting /t REG_DWORD /d 1 /f>nul
105 ::reg add "HKCU\Control Panel\Desktop" /v DragFullWindows /t REG_SZ /d 1 /f>nul
106 ::reg add "HKCU\Control Panel\Desktop" /v FontSmoothing /t REG_SZ /d 2 /f>nul
107 ::reg add "HKCU\Control Panel\Desktop" /v MinAnimate /t REG_SZ /d 1 /f>nul
108 ::reg add "HKCU\Control Panel\Desktop" /v UserPreferencesMask /t REG_BINARY /d 9E3E078012000000 /f>nul
109 echo - Adjust IE Max Connection
110 reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v "MaxConnectionsPer1_0Server" /t REG_DWORD /d 10 /f>nul
111 echo - IE Security Policy
112 REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 0 /f>nul
113 REG ADD "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" /v IsInstalled /t REG_DWORD /d 0 /f>nul
114 Rundll32 iesetup.dll, IEHardenLMSettings
115 Rundll32 iesetup.dll, IEHardenUser
116 Rundll32 iesetup.dll, IEHardenAdmin
117 echo - Disable TCP Auto-Tuning
118 netsh interface tcp set heuristics disabled>nul
119 echo - Change Power Scheme To High Performance
120 powercfg -s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c>nul
121 echo - No Autorun Server Manager
122 REG ADD HKLM\Software\Microsoft\ServerManager /v DoNotOpenServerManagerAtLogon /t REG_DWORD /d 1 /f>nul
123 echo - Disable Password complexity and Minimum password length
124 echo [version]>%gpfile%.inf
125 echo signature="$CHICAGO$">>%gpfile%.inf
126 echo [System Access]>>%gpfile%.inf
127 echo MinimumPasswordLength = 0 >>%gpfile%.inf
128 echo PasswordComplexity = 0 >>%gpfile%.inf
129 secedit /configure /db %gpfile%.sdb /cfg %gpfile%.inf /log %gpfile%.log>nul 2>nul
130 del %gpfile%.inf %gpfile%.sdb %gpfile%.log %gpfile%.jfm /f /q
131 echo - %currentuser%'s Password never expires
132 wmic Path Win32_UserAccount Where Name="%currentuser%" Set PasswordExpires="FALSE">nul
133 echo   PasswordExpires List:
134 wmic useraccount get Name,PasswordExpires
135 echo - Disable Application Experience task schedulers
136 schtasks /change /tn "\Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" /disable>nul 2>nul
137 schtasks /change /tn "\Microsoft\Windows\Application Experience\ProgramDataUpdater" /disable>nul 2>nul
138 schtasks /change /tn "\Microsoft\Windows\Application Experience\StartupAppTask" /disable>nul 2>nul
139 echo - Disable Customer Experience Improvement Program task schedulers
140 schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\Consolidator" /disable>nul 2>nul
141 schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\KernelCeipTask" /disable>nul 2>nul
142 schtasks /change /tn "\Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" /disable>nul 2>nul
143 echo (3/3) Config Windows Feature
144 echo - BitLocker
145 echo - Direct-Play
146 echo - Wireless-Networking
147 echo - qWave
148 echo please wait...
149 PowerShell /Command "&{Install-WindowsFeature "BitLocker","Direct-Play","Wireless-Networking","qWave" -Restart}"
150 echo Completed!
151 echo Press any key to exit...
152 pause>nul
153 :END
154 if exist %getadminfile% ( del %getadminfile% )
155 popd

复制代码

 

Acceleration.Level.ps1

复制代码

 1 function WriteKey($File, $Key)
 2 {
 3     ECHO $Key >> $File;
 4     ECHO '"Acceleration.Level"=dword:00000000' >> $File;
 5     ECHO "" >> $File;
 6 }
 7 
 8 function Generate($File, $ControlSet)
 9 {
10     $Item = Get-Item -Path "HKLM:\HARDWARE\DEVICEMAP\VIDEO";
11     $ValueNames = $Item.GetValueNames();
12     foreach($ValueName in $ValueNames)
13     {
14         if($ValueName.StartsWith("\Device\Video"))
15         {
16             $Value = $Item.GetValue($ValueName);
17             if($Value.Length -gt 43)
18             {
19                 $Guid = $Value.SubString($Value.Length - 43, 38);
20                 $ObjectNumber = $Value.SubString($Value.Length - 4);
21                 try
22                 {
23                     [System.Guid]::Parse($Guid);
24                     [System.Int32]::Parse($ObjectNumber);
25                 }
26                 catch
27                 {
28                     continue;
29                 }
30                 $Path = "HKLM:\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\Video";
31                 $Service = (Get-Item -Path $Path).GetValue("Service");
32                 $Path = "HKLM:\SYSTEM\" + $ControlSet + "\Services\" + $Service;
33                 $ChildItems = Get-ChildItem -Path $Path;
34                 foreach($ChildItem in $ChildItems)
35                 {
36                     if($ChildItem.PSChildName.StartsWith("Device"))
37                     {
38                         $Key = "[" + $ChildItem.Name + "]";
39                         WriteKey $File $Key;
40                     }
41                 }
42                 $Key = "[HKEY_LOCAL_MACHINE\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\" + $ObjectNumber + "]";
43                 WriteKey $File $Key;
44                 $Key = "[HKEY_LOCAL_MACHINE\SYSTEM\" + $ControlSet + "\Control\Video\" + $Guid + "\" + $ObjectNumber + "\Settings]";
45                 WriteKey $File $Key;
46             }
47         }
48     }
49     $VideoControllers = Get-WmiObject -Class Win32_VideoController;
50     foreach($VideoController in $VideoControllers)
51     {
52         $PnPEntities = Get-WmiObject -Class Win32_PnPEntity;
53         foreach($PnPEntity in $PnPEntities)
54         {
55             if($PnPEntity.PNPDeviceID -eq $VideoController.PNPDeviceID)
56             {
57                 $Path = "HKLM:\SYSTEM\" + $ControlSet + "\Control\Class\" + $PnPEntity.ClassGuid;
58                 $ChildItems = Get-ChildItem -Path $Path;
59                 foreach($ChildItem in $ChildItems)
60                 {
61                     try
62                     {
63                         [System.Int32]::Parse($ChildItem.PSChildName);
64                     }
65                     catch
66                     {
67                         continue;
68                     }
69                     $Key = "[" + $ChildItem.Name + "]";
70                     WriteKey $File $Key;
71                     $Key = "[" + $ChildItem.Name + "\Settings]";
72                     WriteKey $File $Key;
73                 }
74             }
75         }
76     }
77 }
78 
79 $File = "Acceleration.Level.reg";
80 New-Item $File -Type File -Force;
81 ECHO "Windows Registry Editor Version 5.00" > $File;
82 ECHO "" >> $File;
83 Generate $File "ControlSet001";
84 Generate $File "ControlSet002";
85 Generate $File "CurrentControlSet";
86 TYPE $File;
87 regedit.exe /s $File;

复制代码

 

<think>嗯,用户问的是如何在银河麒麟V10 SP1系统上使用xserver-xorg-video-dummy和x11vnc建立远程桌面连接。我需要先了解这两个工具的作用和配置步骤。 首先,xserver-xorg-video-dummy是一个虚拟显示驱动,可以在没有物理显示器的情况下创建虚拟显示环境。而x11vnc则是一个VNC服务器,允许远程连接到X会话。用户的需求可能是在没有物理显示器的服务器或设备上启用远程桌面,或者需要多个虚拟显示器支持。 接下来,我得确认银河麒麟V10 SP1是基于哪个Linux发行版的,通常是基于Ubuntu或Debian的,所以安装软件包的命令应该是apt-get。但需要提醒用户可能需要管理员权限,使用sudo。 步骤大概分为安装所需软件包、配置Xorg的虚拟显示、启动Xorg服务、设置x11vnc,以及最后测试连接。过程中需要生成Xorg的配置文件,指定虚拟显示的分辨率和其他参数。然后启动Xorg服务,确保虚拟显示正常运行。之后配置x11vnc监听正确的显示端口,并设置开机启动。 需要注意的地方包括配置文件的正确性,尤其是Identifier、Driver、Screen等部分不能有错误。还有虚拟显示的分辨率设置,用户可能需要根据需求调整。另外,Xorg服务启动时指定的配置文件和虚拟终端可能需要调整,避免与现有显示冲突。 防火墙设置也是一个关键点,如果系统防火墙启用,需要放行VNC的端口,通常是5900。另外,x11vnc可能需要指定密码,确保安全性,用户需要设置强密码。 可能遇到的问题包括Xorg配置错误导致服务无法启动,这时候需要检查日志文件/var/log/Xorg.0.log。还有x11vnc无法连接到正确的虚拟显示,需要确认DISPLAY环境变量是否正确。此外,自启动脚本的权限和配置是否正确,避免重启后服务未运行。 最后,测试连接时使用VNC客户端,如RealVNC或TightVNC,输入服务器的IP和端口,应该就能看到虚拟桌面了。整个过程需要逐步验证每个步骤,确保无误。</think>在银河麒麟V10 SP1系统中,使用xserver-xorg-video-dummy和x11vnc建立远程桌面连接的步骤如下: --- ### 一、安装必要软件包 ```bash sudo apt-get update sudo apt-get install xserver-xorg-video-dummy x11vnc ``` --- ### 二、配置虚拟显示驱动 1. 创建Xorg配置文件: ```bash sudo nano /usr/share/X11/xorg.conf.d/10-dummy.conf ``` 2. 写入以下内容(可自定义分辨率): ```conf Section "Device" Identifier "DummyDevice" Driver "dummy" VideoRam 256000 # 显存大小(单位KB) EndSection Section "Screen" Identifier "DummyScreen" Device "DummyDevice" Monitor "DummyMonitor" SubSection "Display" Depth 24 Modes "1920x1080" # 设置虚拟分辨率 EndSubSection EndSection Section "Monitor" Identifier "DummyMonitor" HorizSync 15.0-60.0 VertRefresh 15.0-60.0 EndSection ``` --- ### 三、启动虚拟X服务器 ```bash Xorg :1 -config /usr/share/X11/xorg.conf.d/10-dummy.conf ``` (`:1`表示使用显示编号1,避免与物理显示器冲突) --- ### 四、配置x11vnc服务 1. 启动x11vnc监听虚拟显示: ```bash x11vnc -display :1 -forever -shared -noxdamage -passwd 您的密码 ``` * `-shared` 允许多用户连接 * `-passwd` 设置连接密码(建议使用复杂密码) 2. 验证服务状态: ```bash netstat -tulnp | grep 5900 # 确认5900端口已监听 ``` --- ### 五、设置开机自启(可选) 1. 创建systemd服务文件: ```bash sudo nano /etc/systemd/system/x11vnc.service ``` 2. 写入以下内容: ```conf [Unit] Description=x11vnc service After=display-manager.service [Service] ExecStart=/usr/bin/x11vnc -display :1 -forever -shared -noxdamage -passwd 您的密码 Restart=always [Install] WantedBy=multi-user.target ``` 3. 启用服务: ```bash sudo systemctl daemon-reload sudo systemctl enable x11vnc sudo systemctl start x11vnc ``` --- ### 六、远程连接 使用VNC客户端(如TigerVNC/RealVNC)连接: - 地址:`IP地址:0`(若使用默认端口5900) - 输入设置的密码 --- ### 常见问题处理 1. **分辨率调整**:修改`10-dummy.conf`中的`Modes`参数 2. **端口冲突**:通过`-rfbport 端口号`指定其他端口 3. **日志查看**:`journalctl -u x11vnc -f` 查看实时日志 4. **防火墙放行**: ```bash sudo ufw allow 5900/tcp ``` --- 通过以上步骤,即可在无物理显示器的环境下建立虚拟桌面,并通过VNC实现远程访问。建议在部署前测试各环节配置,确保服务稳定性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值