; Script written by Trentent Tye
; May 03, 2013
; This scripts purpose is to execute the "klist.exe purge" command
; silently without user intervention
; This script will cause a window to become visible for a few seconds While
; the "yes" command is passed to klist.exe
; Because klist.exe does not use standard IO when outputting to the command
; prompt until all interactions are complete it's not possible to programmatically
; key in on waiting for its prompts. Due to this, I have this script send
; "y" to the window that klist.exe is executing in until klist.exe is terminatedy
; Demonstrates the use of StdinWrite()
;Kills klist.exe first if it exists
$sCommandKill = "taskkill.exe /im klist.exe /f"
Run("taskkill.exe /im klist.exe /f", @SW_SHOW, "")
If ProcessExists("klist.exe") Then
;setting up the command
$sCommand = "klist.exe purge"
$sTitle = "Klist Run Command"
;executes klist.exe with the purge command in a command prompt with a window
;title we can key on.
Run(@ComSpec & " /C title " & $sTitle & "
" & $sCommand, "C:\", @SW_SHOW, "")
WinActivate ( "Klist Run Command")
;purge each entry
;if the process exists then we keep going
if ProcessExists ( "klist.exe" ) Then
$i = 1
$i = 0
Until $i =0