Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 42,468 of 42,547    |
|    Alan K. to Marion    |
|    Re: What is slowing down my WIndows PC &    |
|    01 Sep 25 12:53:26    |
   
   XPost: alt.comp.os.windows-10, alt.comp.os.windows-11   
   From: alan@invalid.com   
      
   On 9/1/25 11:56 AM, Marion wrote:   
   > @echo off   
   > setlocal   
   > REM 20250901 cpu.bat rev 1.5 - what's slowing things down & how to kill it   
   >   
   > :: ---- Config ----   
   > set "EDITOR_PATH=C:\app\editor\txt\vim\vim82\gvim.exe"   
   >   
   > :: ---- Elevation check ----   
   > net session >nul 2>&1   
   > if %errorlevel% neq 0 (   
   > echo Requesting administrator privileges...   
   > powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb   
   RunAs"   
   > exit /b   
   > )   
   >   
   > :: ---- Timestamp and log file ----   
   > for /f %%I in ('powershell -NoProfile -Command "(Get-Date).T   
   String('yyyy-MM-dd_HHmmss')"') do set "TS=%%I"   
   > set "LOGFILE=%TEMP%\cpu_diag_%TS%.log"   
   >   
   > :: ---- Header ----   
   > >> "%LOGFILE%" echo === Diagnostic Run: %DATE% %TIME% on %COMPUTERNAME% ===   
   > >> "%LOGFILE%" echo.   
   >   
   > :: ---- CPU usage (filtered) ----   
   > >> "%LOGFILE%" echo === CPU Usage (WMIC snapshot) ===   
   > wmic path Win32_PerfFormattedData_PerfProc_Process get Name,   
   ercentProcessorTime /format:csv | more >> "%LOGFILE%"   
   >   
   > :: ---- Memory usage (raw) ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Memory Usage (WMIC snapshot) ===   
   > wmic process get Name,ProcessId,WorkingSetSize /format:csv | more >>   
   "%LOGFILE%"   
   >   
   > :: ---- Unresponsive apps ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Unresponsive Apps ===   
   > tasklist /v | findstr /i "Not Responding" >> "%LOGFILE%"   
   >   
   > :: ---- Top CPU consumers (excluding Idle/System/_Total) ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Top 10 CPU Consumers (excluding Idle   
   System/_Total) ===   
   > powershell -NoProfile -Command ^   
   > "Get-Process | Where-Object { $_.Name -notin @('Idle','System','_Total')   
   } | Sort-Object CPU -Descending | Select-Object -First 10 Name,I   
   ,@{N='CPU';E={[math]::Round($_.CPU,2)}} | Format-Table -AutoSize | Out-String   
   -Width 500" ^   
   > >> "%LOGFILE%"   
   >   
   > :: ---- Top Memory consumers ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Top 10 Memory Consumers ===   
   > powershell -NoProfile -Command ^   
   > "Get-Process | Sort-Object WorkingSet -Descending | Select-Object -First   
   10 Name,Id,@{N='Memory(MB)';E={[int]($_.WorkingSet/1MB)}} | Format-Table   
   -AutoSize | Out-String -Width 500" ^   
   > >> "%LOGFILE%"   
   >   
   > :: ---- Resource hogs (CPU > 10 or Memory > 500MB) ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Potential Resource Hogs (CPU > 10 or Memory >   
   500MB) ===   
   > powershell -NoProfile -Command ^   
   > "$procs = Get-Process | Where-Object { $_.CPU -gt 10 -or $_.WorkingSet   
   -gt 500MB }; $procs | Select-Object Name,Id,@{N='CPU';E={[math]:   
   Round($_.CPU,2)}},@{N='Memory(MB)';E={[int]($_.WorkingSet/1MB)}} |   
   Format-Table -AutoSize | Out-String -Width    
   500" ^   
   > >> "%LOGFILE%"   
   >   
   > :: ---- Suggested kill commands ----   
   > >> "%LOGFILE%" echo.   
   > >> "%LOGFILE%" echo === Suggested Manual Kill Commands ===   
   > powershell -NoProfile -Command ^   
   > "$procs = Get-Process | Where-Object { $_.CPU -gt 10 -or $_.WorkingSet   
   -gt 500MB }; $procs | ForEach-Object { \"taskkill /PID $_.Id /F :: $_.Name   
   (CPU=$($_.CPU), Mem=$([int]($_.WorkingSet/1MB))MB)\" }" ^   
   > >> "%LOGFILE%"   
   >   
   > :: ---- Open log in editor or fallback to console ----   
   > if exist "%EDITOR_PATH%" (   
   > start "" "%EDITOR_PATH%" "%LOGFILE%"   
   > ) else (   
   > echo Editor not found at %EDITOR_PATH%. Viewing in console...   
   > type "%LOGFILE%" | more   
   > )   
   >   
   > endlocal   
   >   
   >   
   >   
   I don't know enough. Is this a batch file or powershell?   
   I find some of it interesting. Can't test till I boot up Windows.   
      
   --   
   Linux Mint 22.1, Thunderbird 128.14.0esr, Mozilla Firefox 142.0   
    Alan K.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca