Jump to content
Sign in to follow this  
xircon

Clear out all those useless programs from memory

Recommended Posts

xircon

I occasionally need to clear out all the crud in memory, so I have written a little script to do it and thought someone may find it useful. It uses process explorer from Sysinternals to produce a list of active processes. Processes that have been commented "REMOVE" are closed.

To comment a process in Process explorer, just right click it and enter some text in the box.

#include <array.au3>
Opt("WinTitleMatchMode", 2)

;Run Process Explorer and save text file.
run("C:\ProcessExplorer\procexp.exe")
WinWait("Process Explorer")
sleep(2000)
WinActivate("Process Explorer")
Send("!fs{ENTER}")

$lcount=1

$file=fileopen(@DesktopDir&"\"&"procexp.txt",0)

;Read into array
while 1
    
    $line=filereadline($file,$lcount+1)
    
    If $file = -1 Then
       Exit
    EndIf
        
    $info = StringSplit($line,chr(9))
    
    ;Kill Process off
    if $info[6]="REMOVE" then 
       if ProcessExists($info[1]) then ProcessClose($info[1])
    endif
    
    ;Increment Counter
    $lcount=$lcount+1

WEnd
Edited by xircon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×