コンテンツにスキップ

Windows コマンド

Windows コマンドの備忘録です。

拡張子の表示・非表示

拡張子を表示する

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /d "0" /t  REG_DWORD /f

拡張子を非表示にする

reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /d "1" /t  REG_DWORD /f

参考

https://win2012r2.com/2022/05/19/enable-file-extention-using-powershell/

隠しファイルの表示・非表示

隠しファイルを表示する

reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Hidden" /t REG_DWORD /d "1" /f

隠しファイルを非表示にする

reg add "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Hidden" /t REG_DWORD /d "2" /f

画面ロックまでの時間

コマンドプロンプトを管理者権限で起動します。 /d オプションでロックされるまでの待機時間 (秒) を設定します。 以下のコマンドは、300秒 (5分) を指定しています。

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v InactivityTimeoutSecs /t REG_DWORD /d 300 /f

PC 情報取得コマンド一覧(PowerShell)

概要

Windows 11 以降では wmic コマンドが非推奨になっています。 代わりに PowerShell の CIM コマンドレットを利用することが推奨されます。 以下は PC の基本情報を取得する代表的なコマンドの一覧です。

コマンド一覧

項目 クラス / プロパティ コマンド例 出力例
シリアル番号 Win32_BIOS.SerialNumber (Get-CimInstance Win32_BIOS).SerialNumber ABC1234XYZ
製品名(モデル名) Win32_ComputerSystem.Model (Get-CimInstance Win32_ComputerSystem).Model ThinkPad X1 Carbon Gen 10
メーカー名 Win32_ComputerSystem.Manufacturer (Get-CimInstance Win32_ComputerSystem).Manufacturer LENOVO
OS 名 Win32_OperatingSystem.Caption (Get-CimInstance Win32_OperatingSystem).Caption Microsoft Windows 11 Pro
OS バージョン Win32_OperatingSystem.Version (Get-CimInstance Win32_OperatingSystem).Version 10.0.22631
CPU 名 Win32_Processor.Name (Get-CimInstance Win32_Processor).Name Intel(R) Core(TM) i7-1360P
メモリ容量 Win32_ComputerSystem.TotalPhysicalMemory "{0:N0} GB" -f ((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB) 32 GB
ディスク容量(C: ドライブ) Win32_LogicalDisk.Size / FreeSpace Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" | Select-Object @{Name='Size(GB)';Expression={[math]::Round($_.Size/1GB,0)}}, @{Name='Free(GB)';Expression={[math]::Round($_.FreeSpace/1GB,0)}} Size(GB): 512
Free(GB): 320
コンピュータ名 Win32_ComputerSystem.Name (Get-CimInstance Win32_ComputerSystem).Name MY_PC_001