如何在Windows Server 2012中关闭和打开GUI

如何在Windows Server 2012中关闭和打开GUI

When Server Core originally shipped, a lot of Windows admins avoided it because you could only use the command line, but this changes with Windows Server 2012 which enabled the use of a hybrid mode.

最初提供Server Core时,许多Windows管理员避免使用它,因为您只能使用命令行,但是Windows Server 2012的情况发生了变化,启用了混合模式。

关闭GUI (Turning the GUI Off)

In Windows Server 8 the GUI has kept with the modular nature of recent Windows Server Operating Systems and in turn has become a “Feature”. This makes removing the GUI very easy. To get started launch Server Manager.

在Windows Server 8中,GUI保持了最新Windows Server操作系统的模块化特性,从而成为“功能”。 这使得删除GUI非常容易。 首先,启动服务器管理器。

如何在Windows Server 2012中关闭和打开GUI

Click on Manage, and then select Remove Roles or Features from the menu.

单击管理,然后从菜单中选择删除角色或功能。

如何在Windows Server 2012中关闭和打开GUI

Click next to skip past the before you begin page, then select your server from the server pool and click next.

单击“下一步”跳过“开始之前”页面,然后从服务器池中选择服务器,然后单击“下一步”。

如何在Windows Server 2012中关闭和打开GUI

Since the GUI is not a Role, we can just click next again to skip past the Roles section.

由于GUI不是角色,因此我们可以再次单击下一步以跳过角色部分。

如何在Windows Server 2012中关闭和打开GUI

When you reach the Features page, you need to uncheck the box next to the “User Interfaces and Infrastructure” option, and then click next.

进入“功能”页面时,需要取消选中“用户界面和基础结构”选项旁边的框,然后单击“下一步”。

如何在Windows Server 2012中关闭和打开GUI

Now tick the “Restart Destination Server” box, then click remove.

现在,勾选“重新启动目标服务器”框,然后单击“删除”。

如何在Windows Server 2012中关闭和打开GUI

The GUI will now be removed.

GUI现在将被删除。

如何在Windows Server 2012中关闭和打开GUI

After the binaries are removed your server will automatically reboot.

删除二进制文件后,服​​务器将自动重启。

如何在Windows Server 2012中关闭和打开GUI

Once it comes back up, and you log in, you will only be able to use the command line.

重新启动并登录后,您将只能使用命令行。

如何在Windows Server 2012中关闭和打开GUI

打开GUI (Turning the GUI On)

Once the GUI has been turned off, you will want to know how to get it back. To do this we use SConfig, so go ahead and type SConfig into the command line and hit enter.

GUI关闭后,您将想知道如何找回它。 为此,我们使用SConfig,因此,在命令行中键入SConfig并按Enter。

如何在Windows Server 2012中关闭和打开GUI

You can see near the bottom of the screen that we can use “12” to Restore the GUI, so type 12 and hit enter.

您可以在屏幕底部附近看到我们可以使用“ 12”来还原GUI,因此键入12并按Enter。

如何在Windows Server 2012中关闭和打开GUI

You will be warned that enabling the GUI requires a reboot, click the yes button.

将警告您,启用GUI需要重新启动,然后单击“是”按钮。

如何在Windows Server 2012中关闭和打开GUI

That will kick off DISM which will start to add the binaries for the GUI Shell.

这将启动DISM,它将开始为GUI Shell添加二进制文件。

如何在Windows Server 2012中关闭和打开GUI

When its finished you will be asked if you would like to restart the computer now, type “y” and hit enter to reboot.

完成后,将询问您是否要立即重新启动计算机,请键入“ y”,然后按Enter键重新启动。

使用PowerShell关闭GUI (GUI Off with PowerShell)

You can do the same thing as we did in the GUI much quicker with a PowerShell cmdlet. To do so, open Server Manager, click on Tools and launch PowerShell.

使用PowerShell cmdlet,可以更快地完成与GUI中相同的操作。 为此,请打开服务器管理器,单击“工具”,然后启动PowerShell。

如何在Windows Server 2012中关闭和打开GUI

We can use the Remove-WindowsFeature cmdlet to remove the feature:

我们可以使用Remove-WindowsFeature cmdlet删除功能:

Remove-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

删除Windows功能Server-Gui-Shell,Server-Gui-Mgmt-Infra

Since Remove-WindowsFeature is just an alias, you could also use:

由于Remove-WindowsFeature只是别名,因此您还可以使用:

Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

卸载WindowsFeature Server-Gui-Shell,Server-Gui-Mgmt-Infra

如何在Windows Server 2012中关闭和打开GUI

Not long after you have  hit the enter key, the removal will begin.

按下Enter键后不久,删除操作就会开始。

如何在Windows Server 2012中关闭和打开GUI

When it’s done, you will be notified that you need to restart your server to complete the process, which can be easily done from the current PowerShell window by running:

完成后,将通知您需要重新启动服务器以完成此过程,可以通过运行以下命令从当前PowerShell窗口轻松完成此操作:

Shutdown –r -t 0

Shutdown –r -t 0

如何在Windows Server 2012中关闭和打开GUI

When your machine restarts you will only have the command line to work with .

当您的计算机重新启动时,您将只能使用命令行。

如何在Windows Server 2012中关闭和打开GUI

使用PowerShell打开GUI (GUI On with PowerShell)

The first thing we need to do is get into PowerShell, so type PowerShell and hit enter.

我们需要做的第一件事是进入PowerShell,因此键入PowerShell并按Enter。

如何在Windows Server 2012中关闭和打开GUI

Now we need to use the Add-WindowsFeature to add the components  back:

现在我们需要使用Add-WindowsFeature将组件添加回去:

Add-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

添加Windows功能Server-Gui-Shell,Server-Gui-Mgmt-Infra

Again this is just an alias for:

同样,这只是以下项的别名:

Install-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

安装Windows功能Server-Gui-Shell,Server-Gui-Mgmt-Infra

如何在Windows Server 2012中关闭和打开GUI

When its done, we will need to restart our server by using the Shutdown command:

完成后,我们将需要使用Shutdown命令重新启动服务器:

Shutdown –r -t 0

Shutdown –r -t 0

如何在Windows Server 2012中关闭和打开GUI

When your server reboots you will have the GUI back.

服务器重新启动后,将返回GUI。

翻译自: https://www.howtogeek.com/111967/how-to-turn-the-gui-off-and-on-in-windows-server-2012/