From 393b328ab61b7ac4558fd046b3a84ec82158c07e Mon Sep 17 00:00:00 2001 From: Sten Tijhuis <102481635+Stensel8@users.noreply.github.com> Date: Thu, 27 Feb 2025 23:43:14 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Big=20things=20=F0=9F=91=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed broken downloader links. - Changed the username variable logic so the script can read the full username. - Improved the program updater; it now uses a more verbose logic. It will tell you what it is doing and if it is successful or not. - Changed the Ninite downloader to download and run the installer directly. This is faster and doesn't give a flashing browser window. - Changed some strings/names. - Migrated more components to Winget to ensure correct downloadlinks. - Changed how CPU, GPU, and RAM details are displayed. Refer to this article for more information. Microsoft is deprecating the WMIC command line tool, which is used to retrieve CPU, GPU, and RAM details. The new method uses PowerShell commands to retrieve the same information. This change ensures that the script remains functional in future Windows versions. - Changed the code logic in the KeyGrabber part, to ensure correct working code in newer Windows versions. The keygrabber will now read new registry values to retrieve information. - Bugfix for crashing issue -> REALESDEALS/pcHealth#167. --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- Documentation/changelog.md | 15 +++ Documentation/releases.md | 3 +- README.md | 47 +++---- Scripts/CMD/pcHealth.bat | 162 ++++++++++++++++-------- Scripts/PS1/Get-CPU_GPU_RAM.ps1 | 71 +++++++++++ Scripts/VBS/KeyGrabber.vbs | 180 +++++++++++++++++---------- 7 files changed, 337 insertions(+), 143 deletions(-) create mode 100644 Scripts/PS1/Get-CPU_GPU_RAM.ps1 diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index d211686..56df4fa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,7 @@ --- name: Bug report about: Create a report to help us improve -title: "*Title/ChangeThis* | Bugg | pcHealth" +title: "*Title/ChangeThis* | Bug | pcHealth" labels: bug assignees: '' diff --git a/Documentation/changelog.md b/Documentation/changelog.md index 0deaa9f..ddf5a65 100644 --- a/Documentation/changelog.md +++ b/Documentation/changelog.md @@ -1,5 +1,20 @@ # Changelog.md - pcHealth +## 27-02-2025 – @Stensel8 + +### Changelog +- Fixed broken downloader links. +- Changed the username variable logic so the script can read the full username. +- Improved the program updater; it now uses a more verbose logic. It will tell you what it is doing and if it is successful or not. +- Changed the Ninite downloader to download and run the installer directly. This is faster and doesn't give a flashing browser window. +- Changed some strings/names. +- Migrated more components to Winget to ensure correct downloadlinks. +- Changed how CPU, GPU, and RAM details are displayed. + Refer to [this article](https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242) for more information. Microsoft is deprecating the WMIC command line tool, which is used to retrieve CPU, GPU, and RAM details. The new method uses PowerShell commands to retrieve the same information. This change ensures that the script remains functional in future Windows versions. +- Changed the code logic in the KeyGrabber part, to ensure correct working code in newer Windows versions. The keygrabber will now read new registry values to retrieve information. +- Bugfix for crashing issue -> [REALESDEALS/pcHealth#167](https://github.com/REALESDEALS/pcHealth/issues/167). + + ## 18-10-2024 - @REALSDEALS Audit of the code, everything seems to work in this audit and testing phase. diff --git a/Documentation/releases.md b/Documentation/releases.md index 18d8d28..82223bc 100644 --- a/Documentation/releases.md +++ b/Documentation/releases.md @@ -5,7 +5,7 @@ For now only the version names will be displayed, in the future there might be e # Current Version(s) -Full Release - v1.8.3 (Stable) +Full Release - v1.8.3 (Stable) Beta Release - v1.8.2-beta ======= Alpha Release - v0.3.0-alpha (PowerShell) ((DISCONTINUED)) @@ -16,6 +16,7 @@ Here you can see a overview of the older version. ### Full Release(s) +- [ ] **TODO:** Full Release - V??? - **New version @REALSDEALS?** - Full Release - v1.8.3 - Full Release - v1.7.2 - Full Release - v1.7.0 diff --git a/README.md b/README.md index 61a6225..72fd43c 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ First of all I want to thank you, for downloading and using this script! It really means a lot to me! If you have any tips/tricks or remarks? -Feel free to contact me on discord: REALSDEALS +Feel free to contact me on discord: **REALSDEALS**. -Sidenote: since version 1.6 and onwards, the Powershell section has been removed from the script. To read more about this decision, please read the changelog. +**Sidenote**: since version 1.6 and onwards, the Powershell section has been removed from the script. To read more about this decision, please read the changelog. ### More information regarding on how to install and use it: @@ -25,7 +25,7 @@ Sidenote: since version 1.6 and onwards, the Powershell section has been removed - Open the `scripts` folder and open the CMD folder in there. - Open the file in the CMD folder and read the rules/commands carefully. - Enter in the number of the desired command that you want to run. (Number + ENTER) -- Patiently wait for the script to finish. +- Patiently wait for the script to finish. Some menu-options may take some time to finish. - You can chose, depending on the command, what you want to do next. (Open logs ect.) ### For users that are not that known about what everything may or may not do... @@ -39,8 +39,8 @@ But I can only keep that promise if you are sure to have downloaded pcHealth.bat Otherwise I can keep no promise to that statement. 1. Gather generic information about the system. -2. Check for which CPU and GPU are in the system. -3. Run a scan for corrupt and/or missing files. (Windows iso related) +2. Show CPU, GPU and RAM information. +3. Run a scan for corrupt and/or missing files. (Windows ISO/DISM related) 4. When option 3. can't repair the corrupt/missing files, you can try this option. (DISM) 5. Option 3. and 4. combined. (Puts both commands behind eachother) 6. Generate a battery report. (To see how your laptop battery is doing) @@ -65,34 +65,39 @@ Otherwise I can keep no promise to that statement. ## Programs menu: The entries that you may put in here will redirect you to the download page of the program. -Most of them are 'direct links.' +This is a combination of winget packages and direct download links, since not all programs are available in winget. -I understand if people have their questions about that decision, but I wanted to make it as easy as possible for the you as a user. +While I understand that some of you may have questions about this decision, my goal was to simplify the process for you. You’re welcome to review the source code at any time to see exactly how it works. Additionally, if you prefer to download your software manually, that option is always available. -1. Hardware Info - This program will check which hardware is in your pc etc. -2. ADW Cleaner - This program will scan for malicious software etc. -3. DiskInfo64 - This program will check information about your HDD/SDD (serial etc.) -4. DiskMark64 - This program will test your HDD/SDD on possible malfunctions. -5. Prime95 - This program will stress test your CPU. -6. Windows PowerToys - Makes configuration in- and around Windows a tad easier. -7. Return to the previous menu. +1. Hardware Info - This program will check which hardware is in your PC. +2. HWMonitor - This program will check the temperature of your hardware. +3. ADW Cleaner - This program will scan for malicious software (adware, malware, spyware). +4. DiskInfo64 - This program will check information about your HDD/SDD (serial etc.) +5. CrystalDiskMark 8 - This program will test your HDD/SDD on possible malfunctions. +6. Prime95 - This program will stress test your CPU. Useful for overclocking and performance tests. +7. Windows PowerToys - Makes configuration in- and around Windows a tad easier. Adds some new features to your Windows. 8. Open the other menu, it's called 'Tools'. -9. Close the script. +9. Return to the previous menu. +10. Close the script. ## KeyGrabber The key grabber script does what it says! It grabs the license key (windows) that's on your pc, and gives you an option to save it to your desktop. -### Questions +## Questions If you still have questions, you can send me a message on Discord as mentioned above. -My username is: REALSDEALS +My username is: **REALSDEALS**. There is also a possibility to e-mail me, if that's what you desire (check my GitHub profile for that). -#### Win_Scan +## pcHealthPlus +pcHealthPlus is my other repository, where I plan to gradually migrate the technology currently implemented here. My goal is to transition to PowerShell 7.5, as Microsoft is set to drop support for batch (.bat/.cmd) files in upcoming Windows releases. -Yes, Win_Scan is my other repository, but the function that Win_Scan does has been implemented here... -So you can use both, I'll keep both of them up, but this one will be more advanced when it's finished. +Link to pcHealthPlus: [REALESDEALS/pcHealthPlus](https://github.com/REALSDEALS/pcHealthPlus) -Link to Win_Scan: https://github.com/REALSDEALS/Win_Scan \ No newline at end of file +## Win_Scan +~~Win_Scan is my other repository, but the functionality provided by Win_Scan has been implemented here...~~ +~~The functionality is now fully integrated into this script. The old repository still exists, but it is deprecated.~~ + +~~Link to Win_Scan: [REALESDEALS/Win_Scan](https://github.com/REALSDEALS/Win_Scan)~~ diff --git a/Scripts/CMD/pcHealth.bat b/Scripts/CMD/pcHealth.bat index 78b99d5..d8fb246 100644 --- a/Scripts/CMD/pcHealth.bat +++ b/Scripts/CMD/pcHealth.bat @@ -29,7 +29,7 @@ if '%errorlevel%' NEQ '0' ( :-------------------------------------- :: MainCode @echo off -title pcHealth - Check your PC's Health! - version 1.8.3 +title pcHealth - Check your PC's Health! - version 1.8.5 ======= cd / color D @@ -43,10 +43,12 @@ echo Thanks for downloading and using pcHealth! echo Please be sure that you are running this Batch file in Administrator mode. echo. echo Made by REALSDEALS - Licensed under GNU-3 (You are free to use, but not to change or to remove this line.) -echo You are now using version 1.8.3 of pcHealth. +echo You are now using version 1.8.5 of pcHealth. ======= echo. -ECHO Hello %USERNAME%! +for /f "skip=2 tokens=1,2,*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /v LastLoggedOnDisplayName 2^>nul') do set FullName=%%c +if "%FullName%"=="" set FullName=%USERNAME% +echo Hello %FullName%! echo Today it is '%DATE%' and the time is '%TIME%' echo. echo ........................................................... @@ -75,7 +77,7 @@ echo You are now in the Tools menu: echo. echo ........................................................... echo Enter number 1 to gather generic information about the system. -echo Enter number 2 to see which CPU and GPU are in the system. +echo Enter number 2 to show CPU, GPU and RAM information. echo Enter number 3 to run a system scan for missing/corrupt files. echo Enter number 4 to try and repair missing/corrupt files. echo Enter number 5 to run a system scan and to start an attempt on repairing missing/corrupt files. @@ -132,33 +134,44 @@ echo. echo You are now in the Programs menu: echo. echo ........................................................... -echo Enter number 1 to get hardware info. -echo Enter number 2 to get ADW Cleaner. -echo Enter number 3 to get DiskInfo64. -echo Enter number 4 to get DiskMark64. -echo Enter number 5 to get Prime95. -echo Enter number 6 to install Windows PowerToys. -echo Enter number 7 to open the tools menu. -echo Enter number 8 to return to the previous menu. -echo Enter number 9 to close the script. +echo Enter number 1 to get HWiNFO 64. +echo Enter number 2 to get HWMonitor. +echo Enter number 3 to get Malwarebytes ADW Cleaner. +echo Enter number 4 to get CrystalDiskInfo. +echo Enter number 5 to get CrystalDiskMark. +echo Enter number 6 to get Prime95. +echo Enter number 7 to install Windows PowerToys. +echo Enter number 8 to open the tools menu. +echo Enter number 9 to return to the previous menu. +echo Enter number 10 to close the script. echo ........................................................... echo. SET /P AB=Type one of the numbers above to run the desired function. Enter: IF %AB%==1 GOTO HARDINFODOWN -IF %AB%==2 GOTO ADWCLEANER -IF %AB%==3 GOTO DISKINFODOWN -IF %AB%==4 GOTO DISKMARKDOWN -IF %AB%==5 GOTO PRIMEDOWN -IF %AB%==6 GOTO POWERTOYS -IF %AB%==7 GOTO TOOLS -IF %AB%==8 GOTO MENU -IF %AB%==9 GOTO CLOSE +IF %AB%==2 GOTO HWMONITORDOWN +IF %AB%==3 GOTO ADWCLEANER +IF %AB%==4 GOTO DISKINFODOWN +IF %AB%==5 GOTO DISKMARKDOWN +IF %AB%==6 GOTO PRIMEDOWN +IF %AB%==7 GOTO POWERTOYS +IF %AB%==8 GOTO TOOLS +IF %AB%==9 GOTO MENU +IF %AB%==10 GOTO CLOSE :SYSUPDATE cls color 0A -winget upgrade --all +echo Detected the following updatable packages: +winget upgrade +echo. +set /p update_choice="Do you want to continue updating? (y/n): " +if /i "%update_choice%"=="y" ( + echo Updating packages... + winget upgrade --all +) else ( + echo Update aborted. +) pause echo. SET /P LL=Enter number 1 to return to the sub-menu, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: @@ -191,17 +204,15 @@ IF %D%==4 GOTO CLOSE :CPUANDGPUINFO cls -color 0A -echo. -echo Your CPU information: -echo. -wmic cpu get caption, deviceid, name, numberofcores, maxclockspeed, status +color 0A +echo Gathering CPU, GPU and RAM information. Please be patient... +timeout /t 4 >nul +cls +powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0..\PS1\Get-CPU_GPU_RAM.ps1" +echo -------------------------------------------------------- echo. -echo Your GPU information: echo. -wmic path win32_VideoController get name pause -echo. SET /P E=Enter number 1 to return to the sub-menu, enter number 2 to go back to the main menu or enter number 3 to close the script. Enter: IF %E%==1 GOTO TOOLS IF %E%==2 GOTO MENU @@ -270,17 +281,29 @@ IF %J%==1 GOTO TOOLS IF %J%==2 GOTO MENU IF %J%==3 GOTO CLOSE +:: Generate a battery report :BATTERY cls color 0A +echo Generating a software-based battery report... +echo. +echo Please note: +echo This report is generated from OS data and may differ from the hardware-based battery report offered by some laptops. +echo. powercfg /batteryreport pause echo. -SET /P K=Enter number 1 to open the generated file, enter number 2 to return to the previous sub-menu, number 3 to return to the main-menu or enter number 4 to exit the script. Enter: -IF %K%==1 GOTO BATOPEN -IF %K%==2 GOTO TOOLS -IF %K%==3 GOTO MENU -IF %K%==4 GOTO CLOSE +echo Select an option: +echo 1. Open the generated report +echo 2. Return to the previous sub-menu +echo 3. Return to the main menu +echo 4. Exit the script +echo. +set /p K=Enter your choice (1-4): +if "%K%"=="1" goto BATOPEN +if "%K%"=="2" goto TOOLS +if "%K%"=="3" goto MENU +if "%K%"=="4" goto CLOSE :UPDATE cls @@ -300,9 +323,9 @@ dfrgui.exe pause echo. SET /P LK=Enter number 1 to return to the previous sub-menu, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: -IF %L%==1 GOTO TOOLS -IF %L%==2 GOTO MENU -IF %L%==3 GOTO CLOSE +IF %LK%==1 GOTO TOOLS +IF %LK%==2 GOTO MENU +IF %LK%==3 GOTO CLOSE :CLMGR cls @@ -311,9 +334,9 @@ cleanmgr.exe pause echo. SET /P LKT=Enter number 1 to return to the previous sub-menu, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: -IF %L%==1 GOTO TOOLS -IF %L%==2 GOTO MENU -IF %L%==3 GOTO CLOSE +IF %LKT%==1 GOTO TOOLS +IF %LKT%==2 GOTO MENU +IF %LKT%==3 GOTO CLOSE :SHORTPING cls @@ -391,7 +414,15 @@ IF %P%==3 GOTO CLOSE :NINITE cls color 0A -start "" https://ninite.com/7zip-chrome-edge-vlc/ninite.exe +echo Downloading Ninite installer silently... +set dest=%temp%\ninite.exe +curl -o "%dest%" "https://ninite.com/7zip-chrome-edge-vlc/ninite.exe" +if exist "%dest%" ( + echo Download complete. Launching installer... + start "" "%dest%" +) else ( + echo Failed to download the installer. +) pause echo. SET /P Q=Enter number 1 to return to the previous sub-menu, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: @@ -403,19 +434,16 @@ IF %Q%==3 GOTO CLOSE cls color 0A echo. -echo "Your systems license key:" -wmic path SoftwareLicensingService get OA3xOriginalProductKey -pause +echo Running VBS script to retrieve Windows license. Expect a new window to pop up. +cscript //nologo "%~dp0..\VBS\KeyGrabber.vbs" color 0E echo. -echo If it didn't showed a key, it is possible that this PC is using a 'illegal' key, or a key that was used for a previous installation of Windows 7/8 - then upgraded to 10/11. -echo. -echo You can also try to use a different script for the license key, you can find it in the 'Scripts' folder in this pcHealth folder! echo. +cls SET /p R=If you want to return to the previous sub-menu, enter number 1. To return to the main-menu, enter number 2. To exit the script, enter the number 3. Enter: IF %R%==1 GOTO TOOLS IF %R%==2 GOTO MENU -IF %R%==2 GOTO CLOSE +IF %R%==3 GOTO CLOSE :BIOSPW cls @@ -554,6 +582,29 @@ IF %AF%==1 GOTO PROGRAMS IF %AF%==2 GOTO MENU IF %AF%==3 GOTO CLOSE +:HWMONITORDOWN +cls +color 0A +echo. +echo Are you sure that you want to download the newest version of HWMonitor? +echo. +SET /P AE=If yes, enter the number 1, if not enter number 2 to return to the sub-menu. Enter: +IF %AE%==1 GOTO HARDMONITORDOWNLOADLINK +IF %AE%==2 GOTO PROGRAMS + +:HARDMONITORDOWNLOADLINK +cls +color 0A +echo. +echo Your download will start now; if not click on 'installer' on the download page! +echo. +winget install --id CPUID.HWMonitor +echo. +SET /P AF=To return to the previous sub-menu enter 1, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: +IF %AF%==1 GOTO PROGRAMS +IF %AF%==2 GOTO MENU +IF %AF%==3 GOTO CLOSE + :ADWCLEANER cls color 0A @@ -570,7 +621,10 @@ color 0A echo. echo Your download will start now! echo. -start "" https://downloads.malwarebytes.com/file/adwcleaner +winget install --id Malwarebytes.AdwCleaner +echo. +echo ----------------------------------------------------- +echo To start the program, quit this program with CTRL+C and type 'adwcleaner' in a CMD or Powershell terminal. You might need a reboot for this to work. echo. SET /P AH=To return to the previous sub-menu enter 1, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: IF %AH%==1 GOTO PROGRAMS @@ -592,7 +646,7 @@ cls color 0A echo. echo Your download will start now! -start "" https://sourceforge.net/projects/crystaldiskinfo/files/9.2.1/CrystalDiskInfo9_2_1.exe/download +winget install --id CrystalDewWorld.CrystalDiskInfo echo. SET /P AJ=To return to the previous sub-menu enter 1, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: IF %AJ%==1 GOTO PROGRAMS @@ -603,7 +657,7 @@ IF %AJ%==3 GOTO CLOSE cls color 0A echo. -echo Are you sure that you want to download the latest version of Disk Mark? +echo Are you sure that you want to download the latest version of CrystalDiskMark? echo. SET /P AK=If yes enter the number 1 to start the download, enter the number 2 to return to the previous sub-menu. Enter: IF %AK%==1 GOTO DISKMARKDOWNLOADLINK @@ -614,7 +668,7 @@ cls color 0A echo. echo Your download will start now! -start "" https://sourceforge.net/projects/crystaldiskmark/files/8.0.4c/CrystalDiskMark8_0_4c.exe/download +winget install --id CrystalDewWorld.CrystalDiskMark echo. SET /P AL=To return to the previous sub-menu enter 1, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: IF %AL%==1 GOTO PROGRAMS @@ -636,7 +690,7 @@ cls color 0A echo. echo Your download will start now! -start "" https://www.guru3d.com/getdownload/2c1b2414f56a6594ffef91236a87c0e976d52e051ab2343846bab016c2f20c7c4d6ce7dfe19a0bc843da8d448bbb670058b0c9ee9a26f5cf49bc39c97da070e6eb314629af3da2d25bb346390afa2dcf705c87ec7c3da347e18659a3b948c3070ffcc0d3e8b64372a1b9cb358969eb4e3c0f5dfa331505ae3d1cc694687ac9764e3f9a584af4b257b93021590ebe2718970193f9c9e422bd44cbf572 +start "" https://prime95.net/download/ echo. SET /P AN=To return to the previous sub-menu enter 1, enter number 2 to return to the main-menu or enter number 3 to exit the script. Enter: IF %AN%==1 GOTO PROGRAMS diff --git a/Scripts/PS1/Get-CPU_GPU_RAM.ps1 b/Scripts/PS1/Get-CPU_GPU_RAM.ps1 new file mode 100644 index 0000000..d8bcf76 --- /dev/null +++ b/Scripts/PS1/Get-CPU_GPU_RAM.ps1 @@ -0,0 +1,71 @@ +# Powershell-Helper function to get CPU, GPU, and RAM information. +# Reason: Microsoft has deprecated WIMCI and replaced it with Get-CimInstance. Get-CimInstance is not available in batch mode. +# Microsoft is slowly deprecating older Windows components and replacing it with newer ones. You can read more here: https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242 + + +# ------------------------------- +# 1. CPU Information +# ------------------------------- +$cpuWMI = Get-CimInstance Win32_Processor -ErrorAction SilentlyContinue +$cpu = foreach ($c in $cpuWMI) { + [PSCustomObject]@{ + Name = $c.Name + NumberOfCores = $c.NumberOfCores + NumberOfLogicalProcessors = $c.NumberOfLogicalProcessors + } +} + +# ------------------------------- +# 2. GPU Information +# ------------------------------- +$gpuCIM = Get-CimInstance Win32_VideoController | + Select-Object Name, VideoProcessor, DriverVersion + +$tempFile = "$env:TEMP\dxdiag.txt" +dxdiag /t $tempFile | Out-Null + +$gpuDX = Get-Content $tempFile | Select-String "Dedicated Memory:" | ForEach-Object { + if ($_ -match "Dedicated Memory:\s+(\d+)\s*MB") { + [PSCustomObject]@{ + VRAM_GB = [math]::Round([int]$Matches[1] / 1024, 2) + } + } +} | Where-Object { $_.VRAM_GB -gt 0 } + +if ($gpuCIM.Count -eq $gpuDX.Count) { + $gpuInfo = for ($i = 0; $i -lt $gpuCIM.Count; $i++) { + [PSCustomObject]@{ + Name = $gpuCIM[$i].Name + VideoProcessor = $gpuCIM[$i].VideoProcessor + DriverVersion = $gpuCIM[$i].DriverVersion + DedicatedVRAM_GB = $gpuDX[$i].VRAM_GB + } + } +} else { + $gpuInfo = $gpuCIM +} + +# ------------------------------- +# 3. RAM Information +# ------------------------------- +$ramModules = Get-CimInstance Win32_PhysicalMemory | + Select-Object BankLabel, + @{Name="Capacity(GB)"; Expression={[math]::Round($_.Capacity / 1GB,2)}}, + @{Name="Speed(MT/s)"; Expression={$_.Speed}} + +$slotsUsed = $ramModules.Count +$totalRAM = [math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 2) + +# ------------------------------- +# 4. Output (Formatted Tables) +# ------------------------------- +Write-Host "=== CPU Information ===" -ForegroundColor Cyan +$cpu | Format-Table -AutoSize + +Write-Host "`n=== GPU Information ===" -ForegroundColor Cyan +$gpuInfo | Format-Table -AutoSize + +Write-Host "`n=== RAM Information ===" -ForegroundColor Cyan +$ramModules | Format-Table -AutoSize +Write-Host "`nRAM Slots Used: $slotsUsed" +Write-Host "Total Physical Memory: $totalRAM GB" diff --git a/Scripts/VBS/KeyGrabber.vbs b/Scripts/VBS/KeyGrabber.vbs index e81c800..3281637 100644 --- a/Scripts/VBS/KeyGrabber.vbs +++ b/Scripts/VBS/KeyGrabber.vbs @@ -1,70 +1,118 @@ -Option Explicit - -Dim objshell,path,DigitalID, Result -Set objshell = CreateObject("WScript.Shell") -'Set registry key path -Path = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" -'Registry key value -DigitalID = objshell.RegRead(Path & "DigitalProductId") -Dim ProductName,ProductID,ProductKey,ProductData -'Get ProductName, ProductID, ProductKey -ProductName = "Windows Version: " & objshell.RegRead(Path & "ProductName") -ProductID = "Product ID: " & objshell.RegRead(Path & "ProductID") -ProductKey = "Installed Key: " & ConvertToKey(DigitalID) -ProductData = ProductName & vbNewLine & ProductID & vbNewLine & ProductKey -'Show messbox if save to a file -If vbYes = MsgBox(ProductData & vblf & vblf & "Save your key to a file?", vbYesNo + vbQuestion, "pcHealth | Windows Key Grabber") then - Save ProductData -End If - - - -'Convert binary to chars -Function ConvertToKey(Key) - Const KeyOffset = 52 - Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keypart1, insert - 'Check if OS is Windows 8 - isWin8 = (Key(66) \ 6) And 1 - Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4) - i = 24 - Maps = "BCDFGHJKMPQRTVWXY2346789" +' VBS-Helper function to get Windows version and activation information. +' Reason: Microsoft Windows won't allow us to read out the product key directly, so we need to convert that ourselves. +' Also: Microsoft hasn't made the necessary Registry changes when they introduced Windows 11, +' so we need to check the build number to determine if it's Windows 10 or Windows 11. +' +' This script is called: KeyGrabber.vbs + +Option Explicit + +' ------------------------------- +' 1. Create Shell Object and Define Registry Path +' ------------------------------- +Dim objShell, regPath, currentBuild, ProductName, ProductID, ProductKey, ProductData +Set objShell = CreateObject("WScript.Shell") +regPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\" + +' ------------------------------- +' 2. Read Current Build Number from Registry +' ------------------------------- +currentBuild = CLng(objShell.RegRead(regPath & "CurrentBuild")) + +' ------------------------------- +' 3. Determine OS Name Based on Build Number +' ------------------------------- +If currentBuild >= 22000 Then + ProductName = "Windows 11 " & objShell.RegRead(regPath & "EditionID") +Else + ProductName = objShell.RegRead(regPath & "ProductName") +End If + +' ------------------------------- +' 4. Read Product ID from Registry +' ------------------------------- +ProductID = "Product ID: " & objShell.RegRead(regPath & "ProductID") + +' ------------------------------- +' 5. Read Digital Product ID and Convert to Readable Key +' ------------------------------- +ProductKey = "Installed Key: " & ConvertToKey(objShell.RegRead(regPath & "DigitalProductId")) + +' ------------------------------- +' 6. Combine Product Information into One String +' ------------------------------- +ProductData = "Windows Version: " & ProductName & vbNewLine & ProductID & vbNewLine & ProductKey + +' ------------------------------- +' 7. Prompt User to Save the Key to a File +' ------------------------------- +If vbYes = MsgBox(ProductData & vbNewLine & vbNewLine & "Save your key to a file?", vbYesNo + vbQuestion, "pcHealth | Windows Key Grabber") Then + Save ProductData +End If + +' ------------------------------- +' Function: ConvertToKey +' Converts the binary DigitalProductId into a human-readable product key +' ------------------------------- +Function ConvertToKey(Key) + Const KeyOffset = 52 + Dim isWin8, Maps, i, j, Current, KeyOutput, Last, keyPart1, insert + + ' Determine if the OS is Windows 8 (or newer) based on the key data + isWin8 = (Key(66) \ 6) And 1 + Key(66) = (Key(66) And &HF7) Or ((isWin8 And 2) * 4) + + i = 24 + Maps = "BCDFGHJKMPQRTVWXY2346789" + KeyOutput = "" + + ' Loop through the key bytes to decode the product key Do - Current= 0 - j = 14 + Current = 0 + j = 14 Do - Current = Current* 256 - Current = Key(j + KeyOffset) + Current - Key(j + KeyOffset) = (Current \ 24) - Current=Current Mod 24 - j = j -1 - Loop While j >= 0 - i = i -1 - KeyOutput = Mid(Maps,Current+ 1, 1) & KeyOutput - Last = Current - Loop While i >= 0 - - If (isWin8 = 1) Then - keypart1 = Mid(KeyOutput, 2, Last) - insert = "N" - KeyOutput = Replace(KeyOutput, keypart1, keypart1 & insert, 2, 1, 0) - If Last = 0 Then KeyOutput = insert & KeyOutput - End If - - - ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & Mid(KeyOutput, 6, 5) & "-" & Mid(KeyOutput, 11, 5) & "-" & Mid(KeyOutput, 16, 5) & "-" & Mid(KeyOutput, 21, 5) + Current = Current * 256 + Current = Key(j + KeyOffset) + Current + Key(j + KeyOffset) = (Current \ 24) + Current = Current Mod 24 + j = j - 1 + Loop While j >= 0 + i = i - 1 + ' Prepend the corresponding character from Maps to KeyOutput + KeyOutput = Mid(Maps, Current + 1, 1) & KeyOutput + Last = Current + Loop While i >= 0 + + ' Adjust the output for Windows 8 and later + If isWin8 = 1 Then + keyPart1 = Mid(KeyOutput, 2, Last) + insert = "N" + KeyOutput = Replace(KeyOutput, keyPart1, keyPart1 & insert, 2, 1, 0) + If Last = 0 Then KeyOutput = insert & KeyOutput + End If - -End Function -'Save data to a file -Function Save(Data) - Dim fso, fName, txt,objshell,UserName - Set objshell = CreateObject("wscript.shell") - 'Get current user name - UserName = objshell.ExpandEnvironmentStrings("%UserName%") - 'Create a text file on desktop + ' Insert dashes to format the key in groups of 5 characters + ConvertToKey = Mid(KeyOutput, 1, 5) & "-" & _ + Mid(KeyOutput, 6, 5) & "-" & _ + Mid(KeyOutput, 11, 5) & "-" & _ + Mid(KeyOutput, 16, 5) & "-" & _ + Mid(KeyOutput, 21, 5) +End Function + +' ------------------------------- +' Function: Save +' Saves the provided data to a text file on the user's desktop +' ------------------------------- +Function Save(Data) + Dim fso, fName, txt, objShell, UserName + Set objShell = CreateObject("WScript.Shell") + ' Get the current user name from environment variables + UserName = objShell.ExpandEnvironmentStrings("%UserName%") + ' Define the file path on the desktop fName = "C:\Users\" & UserName & "\Desktop\KeyGrabber - pcHealth.txt" - Set fso = CreateObject("Scripting.FileSystemObject") - Set txt = fso.CreateTextFile(fName) - txt.Writeline Data - txt.Close -End Function \ No newline at end of file + Set fso = CreateObject("Scripting.FileSystemObject") + ' Create the text file and write the data into it + Set txt = fso.CreateTextFile(fName) + txt.WriteLine Data + txt.Close +End Function From 0aa99094ac6a3e6670efe359d59986c9177b70f4 Mon Sep 17 00:00:00 2001 From: Sten Tijhuis <102481635+Stensel8@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:39:45 +0100 Subject: [PATCH 2/3] Correcting a typo --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72fd43c..86ea0b2 100644 --- a/README.md +++ b/README.md @@ -94,10 +94,10 @@ There is also a possibility to e-mail me, if that's what you desire (check my Gi ## pcHealthPlus pcHealthPlus is my other repository, where I plan to gradually migrate the technology currently implemented here. My goal is to transition to PowerShell 7.5, as Microsoft is set to drop support for batch (.bat/.cmd) files in upcoming Windows releases. -Link to pcHealthPlus: [REALESDEALS/pcHealthPlus](https://github.com/REALSDEALS/pcHealthPlus) +Link to pcHealthPlus: [REALSDEALS/pcHealthPlus](https://github.com/REALSDEALS/pcHealthPlus) ## Win_Scan ~~Win_Scan is my other repository, but the functionality provided by Win_Scan has been implemented here...~~ ~~The functionality is now fully integrated into this script. The old repository still exists, but it is deprecated.~~ -~~Link to Win_Scan: [REALESDEALS/Win_Scan](https://github.com/REALSDEALS/Win_Scan)~~ +~~Link to Win_Scan: [REALSDEALS/Win_Scan](https://github.com/REALSDEALS/Win_Scan)~~ From 35ed22fd0b273a30c3017045a2ba97615aff5324 Mon Sep 17 00:00:00 2001 From: Sten Tijhuis <102481635+Stensel8@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:41:27 +0100 Subject: [PATCH 3/3] Update pcHealth.bat --- Scripts/CMD/pcHealth.bat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/CMD/pcHealth.bat b/Scripts/CMD/pcHealth.bat index d8fb246..f0ebfc0 100644 --- a/Scripts/CMD/pcHealth.bat +++ b/Scripts/CMD/pcHealth.bat @@ -29,7 +29,7 @@ if '%errorlevel%' NEQ '0' ( :-------------------------------------- :: MainCode @echo off -title pcHealth - Check your PC's Health! - version 1.8.5 +title pcHealth - Check your PC's Health! - version 1.8.3 ======= cd / color D @@ -43,7 +43,7 @@ echo Thanks for downloading and using pcHealth! echo Please be sure that you are running this Batch file in Administrator mode. echo. echo Made by REALSDEALS - Licensed under GNU-3 (You are free to use, but not to change or to remove this line.) -echo You are now using version 1.8.5 of pcHealth. +echo You are now using version 1.8.3 of pcHealth. ======= echo. for /f "skip=2 tokens=1,2,*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI" /v LastLoggedOnDisplayName 2^>nul') do set FullName=%%c @@ -765,4 +765,4 @@ IF %AS%==2 GOTO TOOLS IF %AS%==3 GOTO CLOSE :CLOSE -EXIT /B \ No newline at end of file +EXIT /B