内気なもんた君

時々日本語化してます

Server 2022 をクライアントOS (デスクトップOS) として使う

Server 2022 をクライアントOS (デスクトップOS) として使う

Windows 11 が目新しい変更も少なくなってきたので、Server をいじって遊んでみる。
だいぶ以前からServerをデスクトップOSとして使うことは一部のユーザーでは取り上げられていたけれど、今回 Canary と同じビルドナンバーの build 25997 が出たのでどんなもんか様子見を兼ねて。

インストール後テキストエディタアーカイバを入れただけの状態ではメモリ使用量1.8GBとわりと少ない。
テレメトリやWindows Updateをあまり気にせず使用できるので、やっぱServerは快適だ。

有効期限がまだ10ヶ月ぐらいあるのでしばらくは楽しめそうだ。

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -

カスタマイズについて

使用するOS : Windows Server VNext Preview ISO (Canary) - Build 25997
      (ログインが必要)

Product Key : Windows Server VNext Datacenter Edition
2KNJJ-33Y9H-2GXGX-KMQWH-G6H67

ISOをダウンロードしたらマウントし任意のフォルダーへコピー。
(ここでは、E:\win\iso とする)
GImageXで install.wim の Index=4 (Datacenter) をエクスポート。
エクスポートした install.wim を E:\win\iso\source へ上書き。
 フォルダ E:\win\iso\mount を作成。

E:\win - iso
           |- mount

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Windows ADK をダウンロードし、Deployment Tools だけインストール。

これで事前準備は完了。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

まず全体のコマンドの流れを説明。

コマンド :

DISM /Mount-Wim /WimFile:E:\win\iso\sources\install.wim /index:1 /MountDir:E:\win\mount
DISM /unmount-WIM /MountDir:E:\win\mount /Commit
DISM /Export-Image /SourceImageFile:E:\win\iso\sources\install.wim /SourceIndex:1 /DestinationImageFile:E:\win\iso\sources\install2.wim /Compress:max
DEL /S /F /Q E:\win\iso\sources\install.wim
REN E:\win\iso\sources\install2.wim install.wim

ISOの作成 :

oscdimg -bE:\win\iso\boot\etfsboot.com -h -u2 -m -lSSS_X64FRE_JA-JP_DV5 E:\win\iso\ E:\win\Server_2022_Datacenter_25997.iso

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

作業の流れ :

1. install.wim をマウント

2. マウントした内容をカスタマイズ(削除、追加等)

3. カスタマイズした内容を install.wim へ適用し、圧縮

4. ISO の作成

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

まず、
DISM /Mount-Wim /WimFile:E:\win\iso\sources\install.wim /index:1 /MountDir:E:\win\mount
でマウントする。

 

ここからは、カスタマイズの内容

パッケージの削除

DISM /image:E:\win\mount /Remove-Package /PackageName:Microsoft-Windows-TabletPCMath-Package~31bf3856ad364e35~amd64~~10.0.25997.1000
DISM /image:E:\win\mount /Remove-Package /PackageName:Microsoft-Windows-MediaPlayer-Package~31bf3856ad364e35~amd64~~10.0.25997.1000
DISM /image:E:\win\mount /Remove-Package /PackageName:Microsoft-Windows-Xps-Xps-Viewer-Opt-Package~31bf3856ad364e35~amd64~~10.0.25997.1000
DISM /image:E:\win\mount /Remove-Package /PackageName:OpenSSH-Client-Package~31bf3856ad364e35~amd64~~10.0.25997.1000

機能の無効

Dism /image:E:\win\mount /Disable-Feature /FeatureName:FileAndStorage-Services
Dism /image:E:\win\mount /Disable-Feature /FeatureName:KeyDistributionService-PSH-Cmdlets
Dism /image:E:\win\mount /Disable-Feature /FeatureName:MediaPlayback
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Printing-PrintToPDFServices-Features
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Printing-XPSServices-Features
Dism /image:E:\win\mount /Disable-Feature /FeatureName:RSAT
Dism /image:E:\win\mount /Disable-Feature /FeatureName:SearchEngine-Client-Package
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Server-Psh-Cmdlets
Dism /image:E:\win\mount /Disable-Feature /FeatureName:SmbDirect
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Storage-Services
Dism /image:E:\win\mount /Disable-Feature /FeatureName:SystemDataArchiver
Dism /image:E:\win\mount /Disable-Feature /FeatureName:TlsSessionTicketKey-PSH-Cmdlets
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Tpm-PSH-Cmdlets
Dism /image:E:\win\mount /Disable-Feature /FeatureName:WCF-Services45
Dism /image:E:\win\mount /Disable-Feature /FeatureName:WCF-TCP-PortSharing45
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Windows-Defender
Dism /image:E:\win\mount /Disable-Feature /FeatureName:WindowsServerBackupSnapin
Dism /image:E:\win\mount /Disable-Feature /FeatureName:Xps-Foundation-Xps-Viewer
Dism /image:E:\win\mount /Disable-Feature /FeatureName:AzureArcSetup
Dism /image:E:\win\mount /Disable-Feature /FeatureName:WorkFolders-Client

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

ファイルの削除

E:\win\mount\Program Files (x86)\Microsoft
所有権を取得しMicrosoftフォルダごと削除

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

SetupComplete.cmdの追加

"E:\win\mount\Windows\Setup\Scripts"
へ SetupComplete.cmd を追加

* SetupComplete.cmd の内容 (サンプル用に一部抜粋)
powercfg -h off
label %SystemDrive% Server 2022
bcdedit /set description "Server 2022"
net accounts /maxpwage:unlimited
REG IMPORT "%SystemRoot%\Setup\Scripts\HKLM.reg"
sc delete edgeupdate
sc delete edgeupdatem
sc delete MicrosoftEdgeElevationService
sc delete WinDefend
sc delete UsoSvc
sc delete wuauserv
sc delete WaaSMedicSvc
sc delete GameInputSvc

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

unattend.xml の追加

"E:\win\mount\Windows\System32\Sysprep"
 へ unattend.xml を追加

unattend.xml はWin11 のものをそのまま使えます。

サーバー用として編集するところ

<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows Server 2022 ServerDatacenter</Value>
</MetaData>

<ProductKey>
<Key>2KNJJ-33Y9H-2GXGX-KMQWH-G6H67</Key>
</ProductKey>

 

注 ) ユーザー名は、Administrator とする。

-----------------------------------------------

カレントユーザーのレジストリエントリを追加する場合

<FirstLogonCommands>
   <SynchronousCommand wcm:action="add">
      <CommandLine>REG IMPORT "%SystemRoot%\Setup\Scripts\HKCU.reg"</CommandLine>
      <Description>IMPORT HKCU</Description>
      <Order>1</Order>
   </SynchronousCommand>
</FirstLogonCommands>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

レジストリエントリのインポートについて

SetupComplete.cmd や unattend.xml へ直接コマンドを書き込むよりも後の編集のしやすさを考えて敢えてインポートにしてます。

インポート用のレジストリファイル ( HKCU.reg、HKLM.reg ) は、
"E:\win\mount\Windows\Setup\Scripts"
へ、置いてます。

注記 :
インポートしたエントリはタイミングのせいなのかログイン後書き換えられてるのか、いくつか適用されていないエントリがあると思います。
その場合、あとで登録するかRunOnceで登録するか小技が必要になります。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

その他 :

aero.theme や壁紙など編集したいものがあれば編集。
追加や削除も各自の好みで行う。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

サーバーをクライアントOSとして使うためのレジストリエントリ

;-----ログオン時サーバーマネージャーを起動しない--------------------------------
[HKCU\SOFTWARE\Microsoft\ServerManager]
"DoNotOpenServerManagerAtLogon"=dword:00000001

;-----IE_ESCの構成-------------------------------------------------------------------
[HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}]
"IsInstalled"=dword:00000000

;-----シャットダウンイベントの追跡ツールを無効-----------------------------------
[HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000
"ShutdownReasonUI"=-
[HKLM\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows NT\Reliability]
"ShutdownReasonOn"=dword:00000000
"ShutdownReasonUI"=-

;-----シャットダウンするのにログオンを必要としない------------------------------
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"shutdownwithoutlogon"=dword:00000001

;-----対話型ログオンCtrl+Alt+Delを必要としない-------------------------------------
[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"disablecad"=dword:00000001

;-----パフォーマンス-----------------------------------------------------------------
[HKLM\SYSTEM\CurrentControlSet\Control\PriorityControl]
"Win32PrioritySeparation"=dword:00000026

;-----コンテキストメニューの「共有」を削除----------------------------------------
[-HKCL\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing]

その他のカスタマイズも、ほぼほぼWin11のものを使えます。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

編集が終わったら、
DISM /unmount-WIM /MountDir:E:\win\mount /Commit
DISM /Export-Image /SourceImageFile:E:\win\iso\sources\install.wim /SourceIndex:1 /DestinationImageFile:E:\win\iso\sources\install2.wim /Compress:max
DEL /S /F /Q E:\win\iso\sources\install.wim
REN E:\win\iso\sources\install2.wim install.wim

で変更を適用し圧縮して終了。

注 :
Commit するときは、エクスプローラは必ず閉じておく。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

ISO の作成 :

oscdimg.exe のあるフォルダでコマンドプロンプトを起動。
ADKをインストールすれば通常は
%ProgramFiles(x86)%\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\x86\Oscdimg

コマンドプロンプト
oscdimg -bE:\win\iso\boot\etfsboot.com -h -u2 -m -lSSS_X64FRE_JA-JP_DV5 E:\win\iso\ E:\win\Server_2022_Datacenter_25997.iso

SSS_X64FRE_JA-JP_DV5 はラベルなので変更してかまわない

 

これで、E:\win へISOが作成されます。

あとは、Rufus でUSBを作成しインストール


SetupComplete.cmd 、 unattend.xml を追加していれば、パーティションを選択した後は完了までノンストップです。