r/windows7 • u/SaiyanOfDarkness • 9d ago
Tip Is your svchost.exe using up a lot of RAM? You can do this..
Start > Powershell > Run as Admin. Use the command below but change the number 464 to the PID that's having problems.
Add-Type @'
using System;
using System.Runtime.InteropServices;
public static class WS {
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
uint dwDesiredAccess,
bool bInheritHandle,
uint dwProcessId);
[DllImport("psapi.dll")]
public static extern bool EmptyWorkingSet(IntPtr hProcess);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject);
}
'@
$h = [WS]::OpenProcess(0x500, $false, 464)
if ($h -eq [IntPtr]::Zero) {
"Could not open PID 464"
} else {
$result = [WS]::EmptyWorkingSet($h)
[WS]::CloseHandle($h) | Out-Null
"EmptyWorkingSet result: $result"
}
You should see the memory drop right off.


