# 내 PC 관리 도우미 - 윈도우 10/11 # 점검과 설정 화면 열기만 합니다. 설치·삭제는 윈도우 화면에서 사용자가 직접 확인합니다. Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing Add-Type -AssemblyName System.IO.Compression Add-Type -AssemblyName System.IO.Compression.FileSystem [Windows.Forms.Application]::EnableVisualStyles() $dataDir = Join-Path $env:LOCALAPPDATA 'PCCareHelper' $historyFile = Join-Path $dataDir 'space_history.csv' if (-not (Test-Path -LiteralPath $dataDir)) { [void](New-Item -ItemType Directory -Path $dataDir) } function Format-GB([double]$bytes) { '{0:N1} GB' -f ($bytes / 1GB) } function Get-CDrive { $d = Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'" -ErrorAction SilentlyContinue if (-not $d) { return $null } [pscustomobject]@{ Size = [double]$d.Size; Free = [double]$d.FreeSpace } } function Open-Target($target, $fallbackMessage) { try { Start-Process $target -ErrorAction Stop } catch { [void][Windows.Forms.MessageBox]::Show($fallbackMessage) } } function Get-History { if (-not (Test-Path -LiteralPath $historyFile)) { return @() } try { return @(Import-Csv -LiteralPath $historyFile -Encoding UTF8) } catch { return @() } } # ---------- 기본 창 ---------- $form = New-Object Windows.Forms.Form $form.Text = '내 PC 관리 도우미' $form.ClientSize = New-Object Drawing.Size(980,640) $form.FormBorderStyle = 'FixedDialog' $form.MaximizeBox = $false $form.StartPosition = 'CenterScreen' $form.Font = New-Object Drawing.Font('Malgun Gothic',10) $tabs = New-Object Windows.Forms.TabControl $tabs.SetBounds(10,10,960,620) $tabs.Font = New-Object Drawing.Font('Malgun Gothic',11) $form.Controls.Add($tabs) function New-Tab($title) { $page = New-Object Windows.Forms.TabPage $page.Text = " $title " $page.Font = New-Object Drawing.Font('Malgun Gothic',10) $page.BackColor = [Drawing.Color]::White [void]$tabs.TabPages.Add($page) return $page } function Add-Label($parent, $text, $x, $y, $w, $h = 26, $bold = $false, $size = 10) { $c = New-Object Windows.Forms.Label $c.Text = $text $c.SetBounds($x,$y,$w,$h) $style = if ($bold) { [Drawing.FontStyle]::Bold } else { [Drawing.FontStyle]::Regular } $c.Font = New-Object Drawing.Font('Malgun Gothic',$size,$style) $parent.Controls.Add($c) return $c } function Add-Button($parent, $text, $x, $y, $w, $action, $h = 42) { $c = New-Object Windows.Forms.Button $c.Text = $text $c.SetBounds($x,$y,$w,$h) $c.Add_Click($action) $parent.Controls.Add($c) return $c } # ---------- 1. PC 상태 확인 ---------- $pStatus = New-Tab '① PC 상태' [void](Add-Label $pStatus '내 PC 정보와 C: 드라이브 용량' 20 18 600 30 $true 13) $statusBox = New-Object Windows.Forms.TextBox $statusBox.Multiline = $true $statusBox.ReadOnly = $true $statusBox.BackColor = [Drawing.Color]::White $statusBox.Font = New-Object Drawing.Font('Malgun Gothic',11) $statusBox.SetBounds(20,60,900,250) $pStatus.Controls.Add($statusBox) $spaceBar = New-Object Windows.Forms.ProgressBar $spaceBar.SetBounds(20,325,900,28) $pStatus.Controls.Add($spaceBar) $spaceHint = Add-Label $pStatus '' 20 360 900 26 function Update-Status { $lines = @() try { $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stop $cs = Get-CimInstance Win32_ComputerSystem -ErrorAction Stop $ver = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -ErrorAction SilentlyContinue) $display = if ($ver.DisplayVersion) { $ver.DisplayVersion } else { $ver.ReleaseId } $lines += "윈도우 : $($os.Caption) $display (빌드 $($os.BuildNumber))" $lines += "PC 제조사 : $($cs.Manufacturer)" $lines += "PC 모델 : $($cs.Model)" $lines += "시스템 종류 : $($os.OSArchitecture)" $lines += "메모리 : $(Format-GB $cs.TotalPhysicalMemory)" } catch { $lines += "PC 정보를 읽지 못했습니다: $($_.Exception.Message)" } $c = Get-CDrive if ($c -and $c.Size -gt 0) { $usedPct = [int](100 * ($c.Size - $c.Free) / $c.Size) $lines += '' $lines += "C: 전체 용량 : $(Format-GB $c.Size)" $lines += "C: 여유 공간 : $(Format-GB $c.Free) (사용 $usedPct%)" $spaceBar.Value = [Math]::Min(100, [Math]::Max(0, $usedPct)) if ($c.Free -lt 20GB) { $spaceHint.Text = '여유 공간이 20GB보다 적습니다. ③ 저장공간 탭에서 정리해 보세요.' $spaceHint.ForeColor = [Drawing.Color]::Firebrick } else { $spaceHint.Text = '여유 공간이 충분합니다.' $spaceHint.ForeColor = [Drawing.Color]::SeaGreen } } $lines += '' $lines += "확인 시각 : $(Get-Date -Format 'yyyy-MM-dd HH:mm')" $statusBox.Text = $lines -join "`r`n" } [void](Add-Button $pStatus '다시 확인' 20 400 160 { Update-Status }) [void](Add-Button $pStatus '정보 복사' 190 400 160 { [Windows.Forms.Clipboard]::SetText($statusBox.Text) [void][Windows.Forms.MessageBox]::Show('PC 정보를 복사했습니다. 문의할 때 붙여넣으세요.') }) [void](Add-Label $pStatus '이 정보는 내 PC 안에서만 확인하며 어디에도 보내지 않습니다.' 20 460 900 26) # ---------- 2. 드라이버 확인 ---------- $pDriver = New-Tab '② 드라이버' [void](Add-Label $pDriver '문제가 있는 장치' 20 18 600 30 $true 13) $devList = New-Object Windows.Forms.ListBox $devList.SetBounds(20,56,900,180) $devList.HorizontalScrollbar = $true $pDriver.Controls.Add($devList) function Update-Devices { $devList.Items.Clear() $bad = @(Get-CimInstance Win32_PnPEntity -ErrorAction SilentlyContinue | Where-Object { $_.ConfigManagerErrorCode -and $_.ConfigManagerErrorCode -ne 0 }) if ($bad.Count -eq 0) { [void]$devList.Items.Add('문제가 표시된 장치가 없습니다.') } else { foreach ($d in $bad) { $name = if ($d.Name) { $d.Name } else { $d.DeviceID } [void]$devList.Items.Add("$name (오류 코드 $($d.ConfigManagerErrorCode))") } } } [void](Add-Button $pDriver '다시 검사' 20 246 140 { Update-Devices }) [void](Add-Label $pDriver '드라이버는 아래 순서로 확인하세요.' 20 310 900 26 $true 11) $isWin11 = ([int](Get-CimInstance Win32_OperatingSystem).BuildNumber) -ge 22000 [void](Add-Button $pDriver '1. Windows 업데이트' 20 345 280 { Open-Target 'ms-settings:windowsupdate' '설정 → Windows 업데이트를 열어 주세요.' }) [void](Add-Button $pDriver '2. 선택적 업데이트(드라이버)' 310 345 300 { if ($isWin11) { Open-Target 'ms-settings:windowsupdate-optionalupdates' '설정 → Windows 업데이트 → 고급 옵션 → 선택적 업데이트를 열어 주세요.' } else { Open-Target 'ms-settings:windowsupdate' 'Windows 업데이트에서 "선택적 업데이트 보기"를 눌러 주세요.' } }) [void](Add-Button $pDriver '3. 장치 관리자' 620 345 300 { Open-Target 'devmgmt.msc' '시작 버튼을 오른쪽 클릭해 장치 관리자를 열어 주세요.' }) [void](Add-Button $pDriver '마이크 선택 확인' 20 400 280 { Open-Target 'ms-settings:sound' '설정 → 시스템 → 소리를 열어 주세요.' }) [void](Add-Label $pDriver ("업데이트에 없으면 PC·장치 제조사 공식 지원 페이지에서 모델에 맞는 드라이버를 받으세요.`r`n" + "설치 후 문제가 생기면 장치 관리자 → 해당 장치 속성 → 드라이버 → '드라이버 롤백'을 누릅니다.") 20 460 900 60) # ---------- 3. 저장공간 정리 ---------- $pSpace = New-Tab '③ 저장공간' [void](Add-Label $pSpace '정리 전후 여유 공간 비교' 20 18 600 30 $true 13) [void](Add-Label $pSpace '정리 전에 [정리 전 기록]을 누르고, 윈도우 저장소 화면에서 정리한 뒤 [정리 후 기록]을 누르세요.' 20 54 900 26) $compareLabel = Add-Label $pSpace '' 20 210 900 60 $true 12 function Add-SpaceRecord($kind) { $c = Get-CDrive if (-not $c) { [void][Windows.Forms.MessageBox]::Show('C: 드라이브를 읽지 못했습니다.'); return } $row = [pscustomobject]@{ Time = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss') Kind = $kind FreeGB = [Math]::Round($c.Free / 1GB, 2) } $rows = @(Get-History) + $row $rows | Export-Csv -LiteralPath $historyFile -Encoding UTF8 -NoTypeInformation Update-Compare } function Update-Compare { $rows = @(Get-History) $before = $rows | Where-Object { $_.Kind -eq '정리 전' } | Select-Object -Last 1 $after = $rows | Where-Object { $_.Kind -eq '정리 후' } | Select-Object -Last 1 $text = @() if ($before) { $text += "정리 전: $($before.FreeGB) GB ($($before.Time))" } if ($after) { $text += "정리 후: $($after.FreeGB) GB ($($after.Time))" } if ($before -and $after -and $after.Time -gt $before.Time) { $diff = [double]$after.FreeGB - [double]$before.FreeGB $text += ('늘어난 공간: {0:N2} GB' -f $diff) } if ($text.Count -eq 0) { $text += '아직 기록이 없습니다.' } $compareLabel.Height = 30 * $text.Count $compareLabel.Text = $text -join "`r`n" } [void](Add-Button $pSpace '정리 전 기록' 20 95 180 { Add-SpaceRecord '정리 전' }) [void](Add-Button $pSpace '저장소 설정 열기' 210 95 200 { Open-Target 'ms-settings:storagesense' '설정 → 시스템 → 저장소를 열어 주세요.' }) [void](Add-Button $pSpace '정리 후 기록' 420 95 180 { Add-SpaceRecord '정리 후' }) [void](Add-Button $pSpace '기록 폴더 열기' 610 95 160 { Open-Target $dataDir $dataDir }) [void](Add-Label $pSpace ("임시 파일은 항목과 용량을 먼저 보고, 필요 없다고 확인한 것만 선택해 제거하세요.`r`n" + "다운로드 폴더와 휴지통은 안에 필요한 파일이 있는지 먼저 확인하세요.`r`n" + "저장 공간 센스를 켤 때는 처음에 '다운로드 자동 삭제'를 끈 상태로 두세요.`r`n" + "이 앱은 파일을 직접 지우지 않습니다.") 20 330 900 110) # ---------- 4. 앱 정리 ---------- $pApps = New-Tab '④ 앱 정리' $apps = @(Get-ItemProperty -Path @( 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' 'HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' ) -ErrorAction SilentlyContinue | Where-Object { $_.DisplayName -and $_.SystemComponent -ne 1 -and $_.UninstallString } | Sort-Object DisplayName, Publisher, DisplayVersion -Unique | ForEach-Object { [pscustomobject]@{ Name = $_.DisplayName Publisher = $_.Publisher Version = $_.DisplayVersion Label = (@($_.DisplayName, $_.DisplayVersion, $_.Publisher) | Where-Object { $_ }) -join ' | ' } }) [void](Add-Label $pApps 'Ctrl을 누른 채 클릭하면 여러 앱을 한 번에 고를 수 있습니다. 실제 제거는 윈도우 설정에서 합니다.' 16 12 920) [void](Add-Label $pApps "설치된 데스크톱 앱 ($($apps.Count)개)" 16 44 450) [void](Add-Label $pApps '삭제 대기 목록' 480 44 450) function New-AppList($x) { $c = New-Object Windows.Forms.ListBox $c.SetBounds($x,72,445,300) $c.SelectionMode = 'MultiExtended' $c.HorizontalScrollbar = $true $c.DisplayMember = 'Label' $pApps.Controls.Add($c) return ,$c } $installed = New-AppList 16 $queued = New-AppList 480 foreach ($app in $apps) { [void]$installed.Items.Add($app) } [void](Add-Button $pApps '선택한 앱 담기 →' 16 385 160 { foreach ($app in @($installed.SelectedItems)) { if (-not $queued.Items.Contains($app)) { [void]$queued.Items.Add($app) } } $installed.ClearSelected() }) [void](Add-Button $pApps '대기 목록에서 빼기' 480 385 160 { foreach ($app in @($queued.SelectedItems)) { $queued.Items.Remove($app) } }) [void](Add-Button $pApps '윈도우 제거 화면 열기' 650 385 200 { Open-Target 'ms-settings:appsfeatures' '설정 → 앱에서 제거 화면을 열어 주세요.' }) $script:archiveFiles = @() $fileStatus = Add-Label $pApps '보관할 파일 0개 선택됨' 16 490 450 [void](Add-Button $pApps '보관할 파일 선택' 16 440 160 { $dialog = New-Object Windows.Forms.OpenFileDialog $dialog.Title = '설치 파일 또는 내보낸 설정 파일 선택' $dialog.Multiselect = $true try { if ($dialog.ShowDialog($form) -eq 'OK') { $script:archiveFiles = @($dialog.FileNames) $fileStatus.Text = "보관할 파일 $($script:archiveFiles.Count)개 선택됨" } } finally { $dialog.Dispose() } }) [void](Add-Button $pApps 'ZIP으로 보관' 186 440 160 { if ($queued.Items.Count -eq 0 -and $script:archiveFiles.Count -eq 0) { [void][Windows.Forms.MessageBox]::Show('앱을 담거나 보관할 파일을 선택해 주세요.') return } $dialog = New-Object Windows.Forms.SaveFileDialog $dialog.Filter = 'ZIP 파일 (*.zip)|*.zip' $dialog.FileName = '앱_정리_보관.zip' $temporary = $null try { if ($dialog.ShowDialog($form) -ne 'OK') { return } $target = $dialog.FileName if ($script:archiveFiles -contains $target) { throw '보관할 파일과 다른 ZIP 이름을 지정해 주세요.' } $temporary = Join-Path ([IO.Path]::GetDirectoryName($target)) ([Guid]::NewGuid().ToString('N') + '.tmp') $archive = [IO.Compression.ZipFile]::Open($temporary, 'Create') try { $entry = $archive.CreateEntry('삭제_대기_목록.csv') $writer = [IO.StreamWriter]::new($entry.Open(), (New-Object Text.UTF8Encoding($true))) try { if ($queued.Items.Count -eq 0) { $writer.WriteLine('Name,Publisher,Version') } else { $queued.Items | Select-Object Name, Publisher, Version | ConvertTo-Csv -NoTypeInformation | ForEach-Object { $writer.WriteLine($_) } } } finally { $writer.Dispose() } $index = 0 foreach ($path in $script:archiveFiles) { $index++ $name = '보관_파일/{0:D3}/{1}' -f $index, [IO.Path]::GetFileName($path) [void][IO.Compression.ZipFileExtensions]::CreateEntryFromFile( $archive, $path, $name, [IO.Compression.CompressionLevel]::Optimal) } } finally { $archive.Dispose() } if ([IO.File]::Exists($target)) { [IO.File]::Replace($temporary, $target, $null) } else { [IO.File]::Move($temporary, $target) } [void][Windows.Forms.MessageBox]::Show("ZIP 저장 완료:`n$target") } catch { [void][Windows.Forms.MessageBox]::Show("ZIP 저장 실패: $($_.Exception.Message)") } finally { if ($temporary -and [IO.File]::Exists($temporary)) { Remove-Item -LiteralPath $temporary -ErrorAction SilentlyContinue } $dialog.Dispose() } }) [void](Add-Label $pApps 'ZIP에는 대기 목록(CSV)과 직접 고른 파일만 들어갑니다.' 16 520 900) # ---------- 5. 느릴 때 ---------- $pSlow = New-Tab '⑤ 느릴 때' [void](Add-Label $pSlow '상황에 맞는 버튼을 누르세요' 20 18 600 30 $true 13) [void](Add-Button $pSlow '로그인부터 느려요 → 시작 앱 점검' 20 64 420 { Open-Target 'ms-settings:startupapps' '작업 관리자(Ctrl+Shift+Esc) → 시작 앱을 열어 주세요.' } 50) [void](Add-Button $pSlow '전체가 느려요 → 작업 관리자' 20 124 420 { Open-Target 'taskmgr.exe' 'Ctrl + Shift + Esc를 눌러 작업 관리자를 열어 주세요.' } 50) [void](Add-Button $pSlow '특정 앱만 느려요 → 앱 복구 화면' 20 184 420 { Open-Target 'ms-settings:appsfeatures' '설정 → 앱을 열어 주세요.' } 50) [void](Add-Button $pSlow 'C: 공간이 부족해요 → 저장공간 탭' 20 244 420 { $tabs.SelectedTab = $pSpace } 50) [void](Add-Label $pSlow ("· 시작 앱은 용도를 아는 앱만 하나씩 끄고, 재부팅 후 비교하세요.`r`n" + "· 작업 관리자에서 CPU·메모리·디스크 중 100%에 가까운 항목을 확인하세요.`r`n" + "· 앱 복구 화면에서 해당 앱의 고급 옵션 → 복구를 먼저 써 보세요.`r`n" + "· '초기화'는 앱 데이터가 지워질 수 있으니 먼저 백업하세요.") 470 70 470 220) # ---------- 시작 ---------- $form.Add_Shown({ $form.Cursor = 'WaitCursor' Update-Status Update-Devices Update-Compare $form.Cursor = 'Default' }) try { [void]$form.ShowDialog() } finally { $form.Dispose() }