@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
title PC 정보 확인 by comfix 2025 (Windows 11 24H2 지원)

REM 출력 파일 설정
set output_file=info.txt
echo ============================================ > %output_file%
echo        사용자 컴퓨터의 정보를 확인합니다      >> %output_file%
echo ============================================ >> %output_file%
echo. >> %output_file%

REM OS 정보 가져오기
for /f "tokens=3 delims= " %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v EditionID') do set SKU=%%a
for /f "tokens=3 delims= " %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild') do set build_num=%%a
for /f "tokens=3 delims= " %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v DisplayVersion') do set version=%%a

REM PowerShell을 이용한 정보 수집
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_OperatingSystem).Caption"') do set os_ver=%%a
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_OperatingSystem).OSArchitecture"') do set os_t=%%a
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_Processor).Name"') do set cpu_name=%%a
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_Processor).MaxClockSpeed"') do set cpu_hz=%%a
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors"') do set lo_processors=%%a

REM 메모리 정보
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1MB"') do set t_mem=%%a

REM 메인보드 정보
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_BaseBoard).Manufacturer"') do set mb_p=%%a
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_BaseBoard).Product"') do set mb_model=%%a

REM 그래픽 카드 정보
for /f "tokens=*" %%a in ('powershell -Command "(Get-CimInstance Win32_VideoController).Name"') do set vga_p=%%a

REM IP 주소, 서브넷 마스크 및 DNS 정보 가져오기
for /f "tokens=*" %%a in ('powershell -Command "(Get-NetIPAddress | Where-Object {$_.AddressFamily -eq 'IPv4' -and $_.InterfaceAlias -ne 'Ethernet 2'} | Select-Object -First 1 -ExpandProperty IPAddress)"') do set ip_address=%%a

REM 서브넷 마스크 가져오기 (PowerShell 사용)
for /f "tokens=*" %%a in ('powershell -Command "(Get-NetIPAddress | Where-Object {$_.AddressFamily -eq 'IPv4' -and $_.InterfaceAlias -ne 'Ethernet 2'} | Select-Object -First 1 -ExpandProperty PrefixLength)"') do set subnet_mask_bits=%%a

REM 서브넷 마스크 비트 수를 255.255.255.0 형식으로 변환
if "%subnet_mask_bits%"=="8" set subnet_mask=255.0.0.0
if "%subnet_mask_bits%"=="16" set subnet_mask=255.255.0.0
if "%subnet_mask_bits%"=="24" set subnet_mask=255.255.255.0
if "%subnet_mask_bits%"=="32" set subnet_mask=255.255.255.255

REM DNS 정보 가져오기
for /f "tokens=*" %%a in ('powershell -Command "(Get-DnsClientServerAddress | Where-Object {$_.InterfaceAlias -ne 'Ethernet 2'} | Select-Object -First 2 -ExpandProperty ServerAddresses)"') do (
    set dns1=%%a
    if not defined dns2 (
        set dns2=%%a
    )
)

REM 출력 파일에 정보 기록
echo.-------------------------------------------- >> %output_file%
echo.  호스트 이름       : %computername% >> %output_file%
echo.-------------------------------------------- >> %output_file%
echo.  운영체제          : %os_ver% >> %output_file%
echo.  빌드 번호         : %build_num% >> %output_file%
echo.  에디션            : %SKU% >> %output_file%
echo.  버전              : %version% >> %output_file%
echo.  커널 아키텍처     : %os_t% >> %output_file%
echo.-------------------------------------------- >> %output_file%
echo.  CPU 모델         : %cpu_name% >> %output_file%
echo.  CPU 속도         : %cpu_hz% MHz * %lo_processors% >> %output_file%
echo.  총 메모리        : %t_mem% MB >> %output_file%
echo.  메인보드         : %mb_p% %mb_model% >> %output_file%
echo.  그래픽 카드      : %vga_p% >> %output_file%
echo.-------------------------------------------- >> %output_file%

echo.  저장 장치        >> %output_file%
REM 저장장치 정보를 가져와서 번호 없이 출력
for /f "tokens=1,2,*" %%a in ('powershell -Command "Get-PhysicalDisk | Select-Object MediaType, Model, @{Name='Size';Expression={[math]::round($_.Size/1GB)}} | ForEach-Object { $_.MediaType + ' ' + $_.Model + ' ' + $_.Size + 'GB' }"') do (
    REM SSD 장치 구분
    if "%%a"=="SSD" (
        echo.  SSD - %%b %%c GB >> %output_file%
    )
    REM HDD 장치 구분
    if "%%a"=="HDD" (
        echo.  HDD - %%b %%c GB >> %output_file%
    )
    REM NVMe 장치 구분
    if "%%a"=="Unspecified" (
        echo.  NVMe - %%b %%c GB >> %output_file%
    )
)

echo.-------------------------------------------- >> %output_file%
echo.  설치된 프린터: >> %output_file%

REM 설치된 프린터 목록에서 첫 번째 프린터만 출력
for /f "tokens=*" %%a in ('powershell -Command "Get-WmiObject -Class Win32_Printer | Select-Object -First 1 -ExpandProperty Name"') do (
    echo.  %%a >> %output_file%
)

echo.-------------------------------------------- >> %output_file%
echo.  IP 주소 정보      : %ip_address% >> %output_file%
echo.  서브넷 마스크     : %subnet_mask% >> %output_file%
echo.  DNS1             : %dns1% >> %output_file%
echo.  DNS2             : %dns2% >> %output_file%
echo. >> %output_file%

REM 화면에 출력
cls
echo ============================================
echo        사용자 컴퓨터의 정보를 확인합니다      
echo ============================================
echo.
echo.--------------------------------------------
echo.  호스트 이름       : %computername%
echo.--------------------------------------------
echo.  운영체제          : %os_ver%
echo.  빌드 번호         : %build_num%
echo.  에디션            : %SKU%
echo.  버전              : %version%
echo.  커널 아키텍처     : %os_t%
echo.--------------------------------------------
echo.  CPU 모델         : %cpu_name%
echo.  CPU 속도         : %cpu_hz% MHz * %lo_processors%
echo.  총 메모리        : %t_mem% MB
echo.  메인보드         : %mb_p% %mb_model%
echo.  그래픽 카드      : %vga_p%
echo.--------------------------------------------

echo.  저장 장치       
REM 저장장치 정보를 가져와서 번호 없이 출력
for /f "tokens=1,2,*" %%a in ('powershell -Command "Get-PhysicalDisk | Select-Object MediaType, Model, @{Name='Size';Expression={[math]::round($_.Size/1GB)}} | ForEach-Object { $_.MediaType + ' ' + $_.Model + ' ' + $_.Size + 'GB' }"') do (
    REM SSD 장치 구분
    if "%%a"=="SSD" (
        echo.  SSD - %%b %%c GB
    )
    REM HDD 장치 구분
    if "%%a"=="HDD" (
        echo.  HDD - %%b %%c GB
    )
    REM NVMe 장치 구분
    if "%%a"=="Unspecified" (
        echo.  NVMe - %%b %%c GB
    )
)

echo.--------------------------------------------
echo.  설치된 프린터:

REM 설치된 프린터 목록에서 첫 번째 프린터만 출력
for /f "tokens=*" %%a in ('powershell -Command "Get-WmiObject -Class Win32_Printer | Select-Object -First 1 -ExpandProperty Name"') do (
    echo.  %%a
)

echo.--------------------------------------------
echo.  IP 주소 정보      : %ip_address%
echo.  서브넷 마스크     : %subnet_mask%
echo.  DNS1             : %dns1%
echo.  DNS2             : %dns2%
echo.
pause
:end
endlocal
