Windows 11の基本設定、おすすめソフトウェア

【概要】Windowsでは、Microsoft社が提供するwinget (Windows Package Manager) パッケージマネージャーを活用し、ビルドツール、開発環境、ユーティリティなどの多くのソフトウェアを効率的にインストールできる。また、不要なプリインストールアプリの削除、ディスクのクリーンアップ、空き領域のゼロフィル(セキュリティ向上のためのデータ消去手法)、長いパス名制限(従来の260文字制限)の緩和、システムサービスの最適化などの設定をコマンドラインから実行できる。さらに、公式ストアやwingetに未収録の有用なフリーソフトウェアを、開発者のWebサイト等から入手できる。

【目次】

  1. DNSサーバアドレスの設定
  2. Windows基本フリーソフトウェアのガイド 〜wingetによる効率的なインストール方法付き〜
  3. Win11Debloat
  4. 不要なプリインストールアプリの削除
  5. サービスの停止
  6. ディスククリーンアップ、デフラグの実行、その他
  7. フリーソフトウェア
  8. WSL2とWSL2上のUbuntu 22.04のインストール
  9. Microsoft PC Manager、Microsoft Sysinternalsツールのダウンロードと設定

【サイト内のWindowsセットアップ関連ページ】

【外部リソース】

1. DNSサーバアドレスの設定

  1. Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。
  2. 次のコマンドを実行する。
    rem すべてのネットワークアダプターの DNS 設定を変更
    for /f "tokens=1,2,3*" %i in ('netsh interface show interface') do (
        if "%i"=="Enabled" (
            netsh interface ipv4 set dns name="%k" static 1.1.1.1 primary
            netsh interface ipv4 add dns name="%k" 1.0.0.1 index=2
        )
    )
    
    rem DNS キャッシュをクリア
    ipconfig /flushdns
    

2. Windows基本フリーソフトウェアのガイド 〜wingetによる効率的なインストール方法付き〜

ここは、Windowsユーザーのためのフリーソフトウェアの案内である。Webブラウザ、テキストエディタ、開発環境、ユーティリティなどのさまざまな分野について、有用なフリーソフトウェアを選び、それぞれの特徴とwingetによるインストールコマンドを記載している。これにより、Windowsの有用なフリーソフトウェアインストールを迅速に、ミスなく行うことができる。

winget

winget (Windows Package Manager) は、Microsoftが開発したWindowsのパッケージマネージャーである。アプリケーションの検索、インストール、更新、削除をコマンドで簡単に行える。最新のWindows 10/11には標準搭載されているが、古いバージョンのWindowsでは手動でインストールする必要がある。

Windowsでのwingetのインストールは、別ページ »で説明する。

インストールコマンド(wingetを最大限利用)

次のコマンドは、AI開発やプログラミングのための基本的なツールがシステム全体(machine scope)にインストールするものである。具体的には、NVIDIA CUDAツールキット 12.6、Python 3.12、Gitバージョン管理システム、CMakeビルドシステム生成ツール、7-Zip圧縮・展開(解凍)ツール、Visual Studio Code、Windsurfである。

winget (Windows Package Manager)を使用してインストールを行う。

  1. Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。
  2. winget (Windows Package Manager)が利用可能か確認する。
    winget --version
    
    wingetバージョン確認画面
  3. 次のコマンドを実行する。

    【注意点】

    • REM の行はメモなので実行する必要はない。
    • winget コマンドは必ず1つずつ実行すること(実行完了を待つため)。
    • Python がすでにインストール済みのときは、「winget install --scope machine --id Python.Python.3.12」の実行のときに、「Modify Repair Uninstall」画面が表示される場合がある。この画面が出た時は、この画面では「Cancel」をクリックして次に進む。
    • winget コマンドが認識されない場合は、Windows 10の場合、Microsoft StoreからApp Installerをインストールする。
    • winget の主要オプションの説明
      • -e:パッケージIDの完全一致検索(曖昧な検索を避ける)。
      • --scope machine:コンピュータ全体(全ユーザー)にインストールする。
    REM Windows のパス長制限(通常260文字)を緩和
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
    reg query "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled
    
    REM winget コマンドは必ず1つずつ実行すること(実行完了を待つため)
    REM Nvidia CUDA 12.6 をシステム領域にインストール
    winget install --scope machine --id Nvidia.CUDA --version 12.6 -e
    
    REM Python, Git, 7zip, Visual Studio Code, Windsurf をシステム領域にインストール
    winget install --scope machine --id Python.Python.3.12 --id Python.Launcher --id Git.Git --id 7zip.7zip --id Microsoft.VisualStudioCode --id Codeium.Windsurf -e --silent
    
    REM 次のコマンドは、複数行を一度に実行してもよい
    REM 次の実行において、特に結果は表示されない。エラーメッセージが出ない場合は実行に成功している
    
    set "INSTALL_PATH=C:\Program Files\Python312"
    echo "%PATH%" | find /i "%INSTALL_PATH%" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%" /M >nul
    echo "%PATH%" | find /i "%INSTALL_PATH%\Scripts" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%\Scripts" /M >nul
    
    set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6"
    if exist "%CUDA_PATH%" setx CUDA_PATH "%CUDA_PATH%" /M >nul
    if exist "%CUDA_PATH%" setx CUDNN_PATH "%CUDA_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Git\cmd"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\7-Zip"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Microsoft VS Code"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Windsurf"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    if exist "C:\Program Files\Microsoft VS Code\bin" cd "C:\Program Files\Microsoft VS Code\bin"
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension ms-python.python
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension MS-CEINTL.vscode-language-pack-ja
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension dongli.python-preview
    

    次のコマンドは、FirefoxGoogle ChromeのWebブラウザ、Build Tools for Visual Studio 2022(ビルドツール for Visual Studio 2022)VLC Media Playerメディアプレイヤー、Blender3次元コンピュータグラフィックス・アニメーションソフト、Search EverythingとEverything ToolbarとQuicklook、AnyTXT Searcherのファイル検索ツール、MobaXtermリモート接続ツール、ShareXスクリーンショットツール、Shotcut動画編集ソフト、OBS Studio配信・録画ソフト、Audacity音声編集ソフト、GIMP画像編集ソフトを、システム全体(machine scope)にインストールするものである。

    winget install --scope machine Mozilla.Firefox
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Mozilla Firefox\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine Google.Chrome.EXE
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Google\Chrome\Application\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine Microsoft.VisualStudio.2022.BuildTools
    winget install --scope machine Microsoft.VCRedist.2015+.x64
    
    winget install --scope machine Kitware.CMake
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\CMake\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine voidtools.Everything
    winget install --scope machine stnkl.everythingtoolbar
    winget install --scope machine ql-win.quicklook
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Everything\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine AnyTXT.AnyTXTSearcher
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files (x86)\AnyTXT Searcher\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine Mobatek.MobaXterm
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files (x86)\Mobatek\MobaXterm\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine ShareX.ShareX
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\ShareX\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine VideoLAN.VLC
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\VideoLAN\VLC\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine blender
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Blender Foundation\Blender 4.2\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine Meltytech.Shotcut
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Shotcut\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine OBSProject.OBSStudio
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\obs-studio\bin\64bit\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine Audacity.Audacity
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Audacity\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    
    winget install --scope machine GIMP.GIMP
    powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\GIMP 2\bin\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
    

Windows基本フリーソフトウェアのガイド

ここでは、上の「wingetによるインストールコマンド」でインストールされるソフトウェアを説明している。

【Webブラウザ】

【プログラミング開発環境】

【ユーティリティ】

Visual Studio設定ガイド

  1. 今度は、Windowsで、コマンドプロンプトを実行する。
  2. 次のコマンドを実行する。

    次のコマンドは、次の拡張機能をインストールするものである。

    • Python language support with extension access points for IntelliSense (Pylance), Debugging (Python Debugger), linting, formatting, refactoring, unit tests, and more.
    • Language pack extension for Japanese
    • Explorer and query SQLite databases
    • Popular extensions for Java development that provides Java IntelliSense, debugging, testing, Maven/Gradle support, project management and more
    • C/C++ IntelliSense, debugging, and code browsing.
    • Python Preview
    cd "c:\Program Files\Microsoft VS Code\"
    code --install-extension ms-python.python
    code --install-extension MS-CEINTL.vscode-language-pack-ja
    code --install-extension alexcvzz.vscode-sqlite
    code --install-extension vscjava.vscode-java-pack
    code --install-extension ms-vscode.cpptools
    code --install-extension dongli.python-preview
    
  3. 次をsettings.jsonに追加する。

    Visual Studio Codeのメニューで、「ファイル (File)」、「基本設定 (Preferences)」、「設定 (Settings)」と操作する。次に、ページの右上にある小さなファイルアイコン(Open Settingsのアイコン)をクリックする。settings.jsonファイルを編集できるようになるので、次を追加する。

    {
      "files.autoSave": "afterDelay",
      "editor.formatOnSave": true,
      "editor.tabSize": 4,
      "editor.fontFamily": "Consolas, 'Courier New', monospace",
      "editor.fontSize": 14,
      "git.enabled": true
    }
    
    Visual Studio Code設定画面

    この追加により、次の設定が行われる。

    • Auto Save: 設定: "files.autoSave": "afterDelay"。作業の中断やクラッシュによるデータ損失を防ぐために、一定の遅延後にファイルを保存する。
    • Format on Save: 設定: "editor.formatOnSave": true。ファイルを保存する際に、自動的にコードのフォーマットを実行し、コードスタイルを自動的に維持する。
    • Editor: Tab Size: 設定: "editor.tabSize": 4 (または2 など)。一貫したインデントを維持し、コードの可読性を向上させる。
    • Font Family and Size: 設定: "editor.fontFamily": "Consolas, 'Courier New', monospace", "editor.fontSize": 14。使用するフォントと大きさの設定。読みやすさを向上させる。
    • Git: Enabled: 設定: "git.enabled": true。Gitバージョン管理機能を有効にし、Visual Studio Code内でのバージョン管理を行えるようにする。

3. Win11Debloat

Win11Debloatは、Windowsの簡素化と最適化を目的としたPowerShellスクリプトである。MITライセンスで公開されている。PowerShellコマンドにより実行可能で、監査モードやユーザー設定の一括適用機能を提供する。主要機能は次の通り。

URL: https://github.com/Raphire/Win11Debloat

4. 不要なプリインストールアプリの削除

アプリの一括削除を行い、その後、アプリを一覧表示する。この処理は、下のスクリプトを用いて実行する。削除されるアプリは、スクリプトの中に記載しているので、確認ならびに必要な変更の上で実行すること。

  1. Windowsで、コマンドプロンプトを実行する。
  2. エディタを起動する。
    cd /d c:%HOMEPATH%
    notepad removeapp.bat
    
    エディタ起動画面
  3. エディタで、次のスクリプトを保存する。

    参考ページ: https://elluminetpress.com/2021/03/uninstall-windows-11-apps-in-powershell/

    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    
    REM Alarms and Clocks
    powershell -command "Get-AppxPackage *WindowsAlarms* | Remove-AppxPackage"
    REM Calculator
    powershell -command "Get-AppxPackage *WindowsCalculator* | Remove-AppxPackage"
    REM Cortana
    powershell -command "Get-AppxPackage *Microsoft.549981C3F5F10* | Remove-AppxPackage"
    REM Feedback Hub
    powershell -command "Get-AppxPackage *WindowsFeedbackHub* | Remove-AppxPackage"
    REM Help and tips
    powershell -command "Get-AppxPackage *GetHelp* | Remove-AppxPackage"
    REM Maps
    powershell -command "Get-AppxPackage *WindowsMaps* | Remove-AppxPackage"
    REM Microsoft To-Do
    powershell -command "Get-AppxPackage *Todos* | Remove-AppxPackage"
    REM Movies and TV
    powershell -command "Get-AppxPackage *ZuneVideo* | Remove-AppxPackage"
    REM Music app
    powershell -command "Get-AppxPackage *ZuneMusic* | Remove-AppxPackage"
    REM News app
    powershell -command "Get-AppxPackage *BingNews* | Remove-AppxPackage"
    REM OneDrive
    powershell -command "Get-AppxPackage *OneDriveSync* | Remove-AppxPackage"
    REM People app
    powershell -command "Get-AppxPackage *Windows.Photos* | Remove-AppxPackage"
    REM Skype
    powershell -command "Get-AppxPackage *SkypeApp* | Remove-AppxPackage"
    REM Solitaire Collection
    powershell -command "Get-AppxPackage *MicrosoftSolitaireCollection* | Remove-AppxPackage"
    REM Spotify
    powershell -command "Get-AppxPackage *SpotifyAB.SpotifyMusic* | Remove-AppxPackage"
    REM Teams/Chat
    powershell -command "Get-AppxPackage *Teams* | Remove-AppxPackage"
    REM Weather
    powershell -command "Get-AppxPackage *BingWeather* | Remove-AppxPackage"
    REM Xbox and related apps
    powershell -command "Get-AppxPackage Microsoft.XboxGamingOverlay | Remove-AppxPackage"
    powershell -command "Get-AppxPackage Microsoft.Xbox.TCUI | Remove-AppxPackage"
    powershell -command "Get-AppxPackage Microsoft.XboxGameOverlay | Remove-AppxPackage"
    powershell -command "Get-AppxPackage Microsoft.XboxIdentityProvider | Remove-AppxPackage"
    powershell -command "Get-AppxPackage Microsoft.XboxSpeechToTextOverlay | Remove-AppxPackage"
    REM Your Phone
    powershell -command "Get-AppxPackage *YourPhone* | Remove-AppxPackage"
    REM AmazonVideo.PrimeVideo
    powershell -command "Get-AppxPackage AmazonVideo.PrimeVideo | Remove-AppxPackage"
    REM
    powershell -command "Get-AppxPackage | Select Name"
    PAUSE
    
    スクリプト編集画面
  4. 実行する。
    cd /d c:%HOMEPATH%
    .\removeapp.bat
    
    スクリプト実行画面
  5. 終了の確認をする。

    アプリが一覧表示され、何かキーを押すと画面が閉じる。

    実行完了画面

5. サービスの停止

サービスの一括削除

サービスの一括削除を行う。この処理は、下のスクリプトを用いて実行する。ここでは、いくつかのアプリを「start=demand」に設定する。設定は、スクリプトの中に記載しているので、確認ならびに必要な変更の上で実行すること。

  1. Windowsで、コマンドプロンプトを実行する。
  2. エディタを起動する。
    cd /d c:%HOMEPATH%
    notepad winservice.bat
    
    エディタ起動画面
  3. エディタで、次のスクリプトを保存する。

    参考ページ: https://elluminetpress.com/2021/03/uninstall-windows-11-apps-in-powershell/

    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    
    REM ActiveX Installer (AxInstSV)
    sc config AxInstSV start=demand
    REM AllJoyn Router Service
    sc config AJRouter start=demand
    REM Connected User Experiences and Telemetry
    sc config DiagTrack start=demand
    REM Distributed Link Tracking Client
    sc config TrkWks start=demand
    REM Geolocation Service
    sc config lfsvc start=demand
    REM Internet Connection Sharing (ICS)
    sc config SharedAccess start=demand
    REM Link-Layer Topology Discovery Mapper
    sc config lltdsvc start=demand
    REM Microsoft Account Sign-in Assistant
    sc config wlidsvc start=demand
    REM Network Connected Devices Auto-Setup
    sc config NcdAutoSetup start=demand
    REM Peer Name Resolution Protocol
    sc config PNRPsvc start=demand
    REM Peer Networking Grouping
    sc config p2psvc start=demand
    REM Peer Networking Identity Manager
    sc config p2pimsvc start=demand
    REM PNRP Machine Name Publication Service
    sc config PNRPAutoReg start=demand
    REM SSDP Discovery
    sc config SSDPSRV start=demand
    REM WalletService
    sc config WalletService start=demand
    REM Windows モバイル ホットスポットサービス
    sc config icssvc start=demand
    REM Xbox Live Auth Manager
    sc config XblAuthManager start=demand
    REM Xbox Live セーブデータ
    sc config XblGameSave start=demand
    REM Xbox Live ネットワーキングサービス
    sc config XboxNetApiSvc start=demand
    REM 市販デモ サービス
    sc config RetailDemo start=demand
    
    REM
    ECHO システムを再起動します
    PAUSE
    Shutdown /r /t 5 /c "REBOOTING THE SYSTEM"
    
    スクリプト編集画面
  4. 実行する。
    cd /d c:%HOMEPATH%
    .\winservice.bat
    
    スクリプト実行画面
  5. 終了の確認をする。

    アプリが一覧表示される。何かキーを押すと、画面が閉じて、システムが再起動する。

    実行完了画面

種々の機能の停止

種々の機能の停止を行う。この処理は、下のスクリプトを用いて実行する。設定は、スクリプトの中に記載しているので、確認ならびに必要な変更の上で実行すること。

  1. Windowsで、コマンドプロンプトを実行する。
  2. エディタを起動する。
    cd /d c:%HOMEPATH%
    notepad wincustom.bat
    
  3. エディタで、次のスクリプトを保存する。
    (Net session >nul 2>&1)||(PowerShell start """%~0""" -verb RunAs & Exit /B)
    
    REM トースト通知をオフにする
    reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" /v "ToastEnabled" /t REG_DWORD /d "0" /f
    
    REM 通知とアクションセンターをオフにする
    reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer" /v "DisableNotificationCenter" /t REG_DWORD /d "1" /f
    
    REM Peopleバーを削除
    reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer" /v "HidePeopleBar" /t REG_DWORD /d "1" /f
    
    REM タスクバーで chat を表示しない
    reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "TaskbarMn" /t REG_DWORD /d "1" /f
    
    REM フリップ3Dを起動しない
    reg add "HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\DWM" /v "DisallowFlip3d" /t REG_DWORD /d "1" /f
    
    REM インターネットを検索しない
    reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\Windows\Explorer" /v "NoSearchInternetInStartMenu" /t REG_DWORD /d "1" /f
    
    REM スタートメニュー検索でウェブの検索結果を表示させない
    reg add "HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer" /v "DisableSearchBoxSuggestions" /t REG_DWORD /d "1" /f
    
    REM Windows 11 ウィジェットを削除する
    reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Dsh" /v "AllowNewsAndInterests" /t REG_DWORD /d "0" /f
    
    REM Windows エラー報告を無効にする
    reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Windows Error Reporting" /v "Disabled" /t REG_DWORD /d "1" /f
    
    REM 場所を無効にする
    reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\LocationAndSensors" /v "DisableLocation" /t REG_DWORD /d "1" /f
    
    REM ようこそ画面を表示しない
    reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explore" /v "NoWelcomeScreen" /t REG_DWORD /d "1" /f
    
    REM
    ECHO システムを再起動します
    PAUSE
    Shutdown /r /t 5 /c "REBOOTING THE SYSTEM"
    
  4. 実行する。
    cd /d c:%HOMEPATH%
    .\wincustom.bat
    
  5. 終了の確認をする。

    何かキーを押すと、画面が閉じて、システムが再起動する。

    実行完了画面

6. ディスククリーンアップ、デフラグの実行、その他

  1. ファンクションキーの無効化

    PowerShellを管理者として実行し、次のコマンドを実行する。

    Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Keyboard Layout" -Name "Scancode Map" -Type Binary -Value ([byte[]](
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
        0x0d,0x00,0x00,0x00,
        0x00,0x00,0x3b,0x00,  # Disable F1
        0x00,0x00,0x3c,0x00,  # Disable F2
        0x00,0x00,0x3d,0x00,  # Disable F3
        0x00,0x00,0x3e,0x00,  # Disable F4
        0x00,0x00,0x3f,0x00,  # Disable F5
        0x00,0x00,0x40,0x00,  # Disable F6
        0x00,0x00,0x41,0x00,  # Disable F7
        0x00,0x00,0x42,0x00,  # Disable F8
        0x00,0x00,0x43,0x00,  # Disable F9
        0x00,0x00,0x44,0x00,  # Disable F10
        0x00,0x00,0x57,0x00,  # Disable F11
        0x00,0x00,0x58,0x00,  # Disable F12
        0x00,0x00,0x00,0x00
    ))
    
  2. Windowsのパス長制限の解除

    Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。

    次のコマンドを実行する。

    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d "1" /f
    
  3. Windowsエクスプローラーで隠しファイルの表示、ファイル名拡張子ファイルの表示

    ファイル名拡張子(.pdf、.pptxなど)が表示されるようになる。そして、隠しファイル(既定では非表示のファイルやフォルダ)が表示されるようになる。

    Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。

    次のコマンドを実行する。

    powershell -command "Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1"
    powershell -command "Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'ShowSuperHidden' -Value 1"
    powershell -command "Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0"
    
  4. ディスククリーンアップ

    Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。

    次のコマンドを実行する。

    cleanmgr /verylowdisk
    
  5. デフラグと、Cドライブの空き領域のゼロフィルを行う。

    sdeleteのURL: https://docs.microsoft.com/ja-jp/sysinternals/downloads/sdelete

    Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。

    次のコマンドを実行する。

    defrag /C /X
    sdelete -z c:
    

7. フリーソフトウェア

winget

wingetは、Microsoftが開発したオープンソースのWindows用パッケージマネージャーである。コマンドラインインターフェースを通じて、ソフトウェアのインストール、更新、削除を行うことができる。wingetは複数のアプリケーションを一度に管理できる上、スクリプトによる自動化も容易である。wingetを使用する際は、いくつかの注意点がある。まず、多くの操作において、管理者権限が必要である。信頼できないソースからのパッケージインストールを行っていないことを、利用者自身が確認する必要がある。wingetでインストールできないソフトウェアも多数あるため、wingetでのインストールと従来のインストールを併用する必要がある。

GPUを利用したAIアプリケーション開発環境のセットアップガイド 〜wingetによる効率的なインストール方法付き〜

次のコマンドは、アプリケーション開発のための基本的な環境をセットアップする。具体的には次の通りである。

  1. 最初に、システムのグラフィックスカード情報を取得し、適切なGPUが利用可能かを確認する。
  2. GitCMakeビルドシステム生成ツール、ビルドツール for Visual Studio 2022、Pythonの基本的な開発ツールをインストールする。
  3. NVIDIA CUDA 12.6とGeForce Experienceをインストールする。

この環境は、GPUを利用したAIアプリケーション開発、C++とPythonを使用したアプリケーション開発に適する。ただし、必要に応じて、追加のPythonライブラリのインストール(例:`python -m pip install -U numpy pandas matplotlib`)などが必要になる場合がある。

  1. Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。
  2. 次のコマンドを実行する。
    wmic path win32_VideoController get name
    
    REM Windows のパス長制限(通常260文字)を緩和
    reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
    reg query "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled
    
    REM winget コマンドは必ず1つずつ実行すること(実行完了を待つため)
    REM Nvidia CUDA 12.6 をシステム領域にインストール
    winget install --scope machine --id Nvidia.CUDA --version 12.6 -e
    
    REM Python, Git, 7zip, Visual Studio Code, Windsurf をシステム領域にインストール
    winget install --scope machine --id Python.Python.3.12 --id Python.Launcher --id Git.Git --id 7zip.7zip --id Microsoft.VisualStudioCode --id Codeium.Windsurf -e --silent
    
    REM 次のコマンドは、複数行を一度に実行してもよい
    REM 次の実行において、特に結果は表示されない。エラーメッセージが出ない場合は実行に成功している
    
    set "INSTALL_PATH=C:\Program Files\Python312"
    echo "%PATH%" | find /i "%INSTALL_PATH%" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%" /M >nul
    echo "%PATH%" | find /i "%INSTALL_PATH%\Scripts" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%\Scripts" /M >nul
    
    set "CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6"
    if exist "%CUDA_PATH%" setx CUDA_PATH "%CUDA_PATH%" /M >nul
    if exist "%CUDA_PATH%" setx CUDNN_PATH "%CUDA_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Git\cmd"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\7-Zip"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Microsoft VS Code"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    set "NEW_PATH=C:\Program Files\Windsurf"
    if exist "%NEW_PATH%" echo "%PATH%" | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    
    if exist "C:\Program Files\Microsoft VS Code\bin" cd "C:\Program Files\Microsoft VS Code\bin"
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension ms-python.python
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension MS-CEINTL.vscode-language-pack-ja
    if exist "C:\Program Files\Microsoft VS Code\bin" code --install-extension dongli.python-preview
    

理工学分野のフリーソフトウェア

理工学分野での研究や開発を支援する多様なフリーソフトウェアを紹介する。Dockerはコンテナ技術を、SQLite3はリレーショナルデータベースを、QGISは地理情報システムを提供する。OctaveとRは数値解析や統計分析を、AnacondaはPythonプログラミング環境を、LaTeXは高品質な文書作成を可能にする。さらに、FreeCADは画像編集から3Dモデリングまで、各種のビジュアル作成・編集を支える。そしてKiCadはPCB設計を効率化する。

その他、便利な機能をもったフリーソフトウェアの紹介

【サイト内の主なWindows関連ページ】

8. WSL2のインストール、WSL2上のサブシステムとしてUbuntu 22.04をインストール

WSL2

WSL 2 (Windows Subsystem for Linux)WSL 2上のUbuntu 22.04のインストールにより、プログラミング等で便利な場合がある。

WSL 2のインストールにより、Ubuntu、Debian、openSUSEのLinuxディストリビューションをWindowsにインストールし、Windowsのサブシステムとして動かすことができるようになる。

WSLのコマンド

【サイト内の関連ページ】

Windows 11での手順を示す。

  1. 「Windowsの機能の有効化または無効化」で、Hyper-V、Linux用Windowsサブシステム、仮想マシンプラットフォームを有効にする。
    1. Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。
    2. Windowsの更新

      次のコマンドを実行する。

      powershell -command "Start-Process ms-settings:windowsupdate"
      
    3. Hyper-V、Linux用Windowsサブシステム、仮想マシンプラットフォームを有効にする。

      次のコマンドを実行する。

      powershell -command "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -n"
      powershell -command "Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform -n"
      powershell -command "Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -n"
      powershell -command "Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -n"
      
    4. その後、Windowsの再起動を行う。

      次のコマンドを実行する。

      shutdown /r /t 0
      
  2. システムの再起動が終わったら、再び、Windowsで、コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニューを押し、「cmd」と入力し、右クリックメニューなどで「管理者として実行」を選択する)。
  3. Windows Subsystem for Linux、仮想マシンプラットフォームのオプションコンポーネントを有効化する。WSLの既定(デフォルト)のバージョンを2に設定する。

    次のコマンドを実行する。

    powershell -command "dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart"
    powershell -command "dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart"
    wsl --set-default-version 2
    
  4. インストール可能なLinuxディストリビューションの確認をする。

    次のコマンドを実行する。

    wsl -l --online
    
  5. Ubuntu-22.04を、Linuxサブシステムとしてインストールする。

    次のコマンドを実行する。このときに、ユーザー名とパスワードの設定が求められる。

    このときに設定したパスワードは、sudoコマンドの実行で必要になるので覚えておくこと。パスワードが画面に表示されないのは正常な動作である。

    wsl --update
    wsl --install -d Ubuntu-22.04
    
  6. Linuxサブシステムのbashシェルを起動する。

    次のコマンドを実行する。

    wsl
    
  7. bashシェルで確認のため、次のコマンドを実行する。このとき、先ほど設定したパスワードを入れる。
    sudo ls
    
  8. ダウンロード元が海外(Ubuntu本家やfr)になっている場合、日本に設定し、OSのシステム更新、C/C++コンパイラ、Python 3ヘッダファイル・ライブラリ、エディタnotepadqq等のインストールを行う。
    sudo sed -i 's/\/\/archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
    sudo sed -i 's/\/\/us.archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
    sudo sed -i 's/\/\/fr.archive.ubuntu.com/\/\/jp.archive.ubuntu.com/g' /etc/apt/sources.list
    sudo apt -y update
    sudo apt -yV upgrade
    sudo apt -yV dist-upgrade
    sudo apt -y install build-essential python3-dev python3-pip notepadqq
    exit
    

9. Microsoft PC Managerのインストール、Microsoft Sysinternalsツールのダウンロードと設定

Microsoft PC Manager

Microsoft PC Managerの公式ページhttps://pcmanager.microsoft.com/ja-jpを開き、「Download」をクリックしてダウンロードする。Microsoft PC Managerをインストールしたら