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

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

目次

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

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

Windows 11インストールガイドは別ページ »で説明する。

1. Windows システムの基本操作について

Windows システムの基本操作ガイドを, 別ページ »で説明している.

2. 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
    

3. 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
    
  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 をシステム領域にインストール
    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\blender.exe\"; [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\obs-studio\bin\64bit\"; [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
    }
    

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

    • 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内でのバージョン管理を行えるようにする。

4. Win Debloat Tools

このツールを実行する前に、このツール自体の安全性を利用者自身で確認すること。

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

    次のコマンドは、GitとDebloat Toolsをインストールし、パスを通すものである。

    winget install --scope machine Git.Git
    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
    
    cd /d c:%HOMEPATH%
    "C:\Program Files\Git\cmd\git.exe" clone https://github.com/LeDragoX/Win-Debloat-Tools
    cd Win-Debloat-Tools
    powershell
    .\OpenTerminalHere.cmd
    
  3. 画面が変わるので、次のコマンドを実行する。
    Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force; ls -Recurse *.ps*1 | Unblock-File; .\"WinDebloatTools.ps1"
    
  4. 画面を確認する。

    よくわからない場合には無理に使い続けないこと。

  5. 「Apply Tweaks」をクリックする。処理が終了したら、システムを再起動する。

    設定を変えたいときは、もう一度、このソフトを起動して、設定を変えて、「Apply Tweaks」をクリックする。元に戻したいときは、このソフトを起動して「Undo Tweaks」をクリックする。

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

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

  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. 終了の確認をする。

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

6. サービスの停止

サービスの一括削除

サービスの一括削除を行う。 この処理は、下のスクリプトを用いて実行する。 ここでは、いくつかのアプリを「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 Telemetsc config DiagTrack start=demand
    REM Distributed Link Tracking Client
    sc config TrkWks start=demand
    REM Geolocation Service
    sc config lfsvc start=demand
    REM Internet Connetion 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. 終了の確認をする。

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

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

  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:
    

8. フリーソフトウェア

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 をシステム領域にインストール
    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
    

その他のアプリのインストール

ディープラーニング関連、プログラミング関連のフリーソフトウェアのインストール

NVIDIAドライバ、NVIDIA CUDAツールキット 12.6、NVIDIA cuDNN 8.6

サイト内の関連ページWindowsでのBuild Tools for Visual Studio 2022NVIDIAドライバNVIDIA CUDAツールキット 12.6、NVIDIA cuDNN v8.9.7のインストールと動作確認は、別ページ »で説明する。

PyTorch

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

    PyTorchの公式ページ: https://pytorch.org/index.html

  3. 次のようなコマンドを実行する(実行するコマンドは、PyTorchのページに表示されるコマンドを使用する)。

    次のコマンドを実行することにより、 PyTorch 2.3(NVIDIA CUDA 12.6用)がインストールされる。 ただし、Anaconda3を使用したい場合には別手順になる。

    事前にNVIDIA CUDAのバージョンを確認しておくこと(ここでは、NVIDIA CUDAツールキット 12.6が前もってインストール済みであるとする)。

    PyTorchで、GPUが動作している場合には、「torch.cuda.is_available()」により、Trueが表示される。

    python -m pip install -U --ignore-installed pip
    python -m pip uninstall -y torch torchvision torchaudio torchtext xformers
    python -m pip install -U torch torchvision torchaudio numpy --index-url https://download.pytorch.org/whl/cu118
    
    python -c "import torch; print(torch.__version__, torch.cuda.is_available())"
    

    Anaconda3を使用したい場合には、 Anacondaプロンプト (Anaconda Prompt)管理者として実行し、 次のコマンドを実行する (PyTorchとNVIDIA CUDAとの連携がうまくいかない可能性があるため、Anaconda3を使用しないことも検討すること)。

    conda install -y pytorch torchvision torchaudio pytorch-cuda=12.6 cudnn -c pytorch -c nvidia
    py -c "import torch; print(torch.__version__, torch.cuda.is_available())"
    

    サイト内の関連ページ

    関連する外部ページ

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

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

関連する外部ページ

  • RStudio Desktop
  • Anaconda: データサイエンス、科学技術計算向けのPythonのディストリビューション
  • LaTeX: 文書作成のための組版システム
  • FreeCAD: 3D CADモデリングソフトウェア。機械設計やプロトタイピングに役立つ。
  • KiCad: PCB設計ソフトウェア。回路設計や基板設計に役立つ。
  • その他、便利な機能をもったフリーソフトウェアの紹介

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

    9. 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
      

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

    Microsoft PC Manager

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

    Microsoft Sysinternalsツール

    Windows Sysinternalsツールは、マイクロソフトが提供する一連のシステムツールのセットである。

    Windows Sysinternalsツールの公式ページ: https://docs.microsoft.com/sysinternals/

    その中の、特に便利なツールには、次のようなものがある。

    Microsoft Sysinternalsツールをダウンロードしてパスを通す手順

    次を実行することにより、Microsoftの「Sysinternals」公式ページからツールをダウンロードし、 c:\SysinternalSuiteに展開し、パスを通すことができる。 Windows Sysinternalsツールの利用条件については、利用者自身で確認すること。

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

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

      cd /d c:%HOMEPATH%
      curl -O https://download.sysinternals.com/files/SysinternalsSuite.zip
      mkdir c:\SysinternalSuite
      powershell -command "Expand-Archive -Path SysinternalsSuite.zip" c:\SysinternalSuite
      powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\SysinternalSuite"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"