Option Explicit ' Alle variabler SKAL dimmes! (dvs: dim variabelnavn)
' ----
' LUKNING AF SYSTEMPROCESSER KAN GØRE COMPUTEREN USTABIL!
' BRUGES PÅ EGET ANSVAR!
' ---
dim proc_list, maa_ikke_lukkes_ned
' Format er: NAVN efterfulgt af KOLON
'
' Eksempel: maa_ikke_lukkes_ned = "svchost.exe:explorer.exe:"
'
' ------ Indsæt navnene her ------
maa_ikke_lukkes_ned = "SMAgent.exe:svchost.exe:SMax4.exe:usnsvc.exe:SMax4PNP.exe:services.exe:alg.exe:googletalk.exe:ctfmon.exe:nvsvc32.exe:MDM.EXE:jusched.exe:lsass.exe:winlogon.exe:csrss.exe:smss.exe:cvpnd.exe:firefox.exe:System:"
' Hent alle de kørende processer:
proc_list = GetList
' Fjern dem der ikke må lukkes:
proc_list = ParseList(LCase(proc_list), LCase(maa_ikke_lukkes_ned))
' Luk resten af processerne der er tilbage i listen:
KillProcess(proc_list)
' ------ Systemet:
' Free Sample VBScript to discover which processes are running
' Author Guy Thomas
http://computerperformance.co.uk/' Version 1.4 - December 2005
' -------------------------------------------------------'
function GetList()
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
strList = strList & objProcess.Name & ":"
Next
'WSCript.Echo strList
' End of List Process Example VBScript
GetList = strList
end function
function ParseList(proc_list, maa_ikke_lukkes_ned)
maa_ikke_lukkes_ned = split(maa_ikke_lukkes_ned, ":")
dim i
for i = LBound(maa_ikke_lukkes_ned) to Ubound(maa_ikke_lukkes_ned)
proc_list = replace(proc_list, maa_ikke_lukkes_ned(i) & ":", "")
next
ParseList = proc_list
end function
'function KillProcess(processnames)
'dim objShell
'Set objShell = CreateObject("WScript.Shell")
'
'dim names, params
'names = split(processnames, ":")
'
'dim i
'for i = Lbound(names) to UBound(names)
' if _
' names(i) <> "" _
' and _
' LCase(names(i)) <> "wscript.exe" _
' and _
' LCase(names(i)) <> "wscript" _
' then
'
' params = " /IM " & names(i) & params
' end if
'next
'
'' Luk alle processerne i listen:
'msgbox "Scriptet ville have lukket:" & vbCrLf & params
'
'' ADVARSEL: Fjern kommentaren ('-tegnet) fra næste linie, for at aktivere scriptet!
'objShell.Run "TASKKILL /F" & params
'set objShell = nothing
'end function
function KillProcess(processnames)
dim objShell
Set objShell = CreateObject("WScript.Shell")
dim names, params
names = split(processnames, ":")
dim i
for i = Lbound(names) to UBound(names)
if _
names(i) <> "" _
and _
LCase(names(i)) <> "wscript.exe" _
and _
LCase(names(i)) <> "wscript" _
then
msgbox "Scriptet ville have lukket:" & vbCrLf & names(i)
objShell.Run "TASKKILL /F /IM " & names(i)
end if
next
set objShell = nothing
end function