Windows11 Yapı 22H2 kullandığım betik yapı sürümü 24H2 kullanılmaz duruma gelince araştırdım.Meğer gözleri kör olsun bu hintlilerin...PowerShell.exe dosyasının yerini değiştirmişler.Anlayacağım diye baya bir uğraştım...Biraz da YZ'den yardım aldım.
Sonuç bu :

En Çok RAM Tüketen 5 İşlem Versiyon 2.vbs
Kod: Tümünü seç
' Windows 11 24H2 uyumlu — MsgBox gösterir, Tamam'a basınca masaüstüne kaydeder
Option Explicit
Dim objShell, fso, psExe, psCmd, objExec
Dim raw, errText, lines, line, parts
Dim processList(), svchostCount, i
Dim processName, ramUsage, j, k, temp, ramInMB, output
Dim desktopPath, outFile, tempPath
Set objShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
psExe = ""
' Önce PowerShell 7, sonra klasik PowerShell kontrolü
If fso.FileExists("C:\Program Files\PowerShell\7\pwsh.exe") Then
psExe = "C:\Program Files\PowerShell\7\pwsh.exe"
ElseIf fso.FileExists("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe") Then
psExe = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
Else
MsgBox "Hata: PowerShell bulunamadı!", vbCritical, "Hata"
WScript.Quit
End If
' PowerShell komutu: ProcessName|WorkingSet64 formatı üretir
psCmd = """" & psExe & """" & " -NoProfile -Command ""Get-Process | Where-Object { $_.ProcessName -ne 'powershell' -and $_.ProcessName -ne 'pwsh' } | ForEach-Object { $_.ProcessName + '|' + ($_.WorkingSet64) } | Out-String -Width 4096"""
Set objExec = objShell.Exec(psCmd)
' Ham stdout/stderr al
On Error Resume Next
raw = objExec.StdOut.ReadAll
errText = objExec.StdErr.ReadAll
On Error GoTo 0
If Len(Trim(raw)) = 0 Then
' Hata durumunda ham çıktıyı inceleme için kaydet
tempPath = objShell.ExpandEnvironmentStrings("%TEMP%") & "\ps_raw.txt"
Set outFile = fso.CreateTextFile(tempPath, True, False)
outFile.WriteLine "STDOUT:"
outFile.WriteLine raw
outFile.WriteLine
outFile.WriteLine "STDERR:"
outFile.WriteLine errText
outFile.Close
MsgBox "PowerShell çıktı alınamadı. Ham çıktı kaydedildi: " & tempPath, vbExclamation, "Hata"
WScript.Quit
End If
svchostCount = 0
i = 0
' Satırlara ayır ve "Name|Bytes" formatını işle
lines = Split(raw, vbCrLf)
For Each line In lines
line = Trim(line)
If line <> "" Then
If InStr(line, "|") > 0 Then
parts = Split(line, "|")
processName = Trim(parts(0))
On Error Resume Next
ramUsage = CDbl(Trim(parts(1))) ' bytes (WorkingSet64)
If Err.Number <> 0 Then
ramUsage = 0
Err.Clear
End If
On Error GoTo 0
If LCase(processName) <> "powershell" And LCase(processName) <> "pwsh" Then
ReDim Preserve processList(i)
processList(i) = Array(processName, ramUsage)
i = i + 1
End If
If LCase(processName) = "svchost" Or LCase(processName) = "svchost.exe" Then
svchostCount = svchostCount + 1
End If
End If
End If
Next
If i = 0 Then
tempPath = objShell.ExpandEnvironmentStrings("%TEMP%") & "\ps_raw.txt"
Set outFile = fso.CreateTextFile(tempPath, True, False)
outFile.WriteLine raw
outFile.WriteLine errText
outFile.Close
MsgBox "Hiç işlem ayrıştırılamadı. Ham PowerShell çıktısı: " & tempPath, vbExclamation, "Hata"
WScript.Quit
End If
' RAM kullanımına göre sıralama (az -> çok yerine çok -> az)
For j = 0 To UBound(processList) - 1
For k = j + 1 To UBound(processList)
If CDbl(processList(j)(1)) < CDbl(processList(k)(1)) Then
temp = processList(j)
processList(j) = processList(k)
processList(k) = temp
End If
Next
Next
' Çıktıyı hazırla (ilk 5)
output = "En çok RAM tüketen 5 işlem:" & vbCrLf
For j = 0 To Min(4, UBound(processList))
ramInMB = processList(j)(1) / 1024 / 1024
output = output & processList(j)(0) & " (" & Round(ramInMB, 2) & " MB)" & vbCrLf
Next
output = output & "svchost.exe işlemlerinin sayısı: " & svchostCount
' Ekranda göster
MsgBox output, vbInformation, "RAM Kullanım Raporu"
' Tamam'a basıldıktan sonra masaüstüne kaydet
desktopPath = objShell.SpecialFolders("Desktop") & "\ram_rapor.txt"
Set outFile = fso.CreateTextFile(desktopPath, True)
outFile.WriteLine output
outFile.Close
Function Min(a, b)
If a < b Then
Min = a
Else
Min = b
End If
End Function
İsteyen kullansın.Benim işimi görüyor.



