Kill a process

Hi,

How can I terminate process using vbscript. PLEASE NOTE, I need to terminate process that runs under windows 64-bit environment as native 64 (not using select * from win_32_Process)

Moving to windows subforum

I use this script .vbs:

Set WshShell = WScript.CreateObject("WScript.Shell") 
Dim MsgBox2,Q,message 
MSGBOXTitle ="Taskkill Tool 2012" 
Q = InputBox("What is the name of the .exe you want me to kill???  Enter it as name.exe" , MSGBOXTitle) 
MsgBox "The following file will be killed: " & Q 
strCommand = "taskkill /F /IM " & Q   
WshShell.Run strCommand, 0, TRUE  
message = "Thanks for using the tool to kill processes!" 
MsgBox2 = MsgBox(message,vbExclamation,MSGBOXTitle) 

NB Taskkill must be in your path.

Try and let me know.

I have run this code,
nMaxRunTime=180
intCount = 0
strProcessKill = "'notepad.exe'"
Set WshShell = WScript.CreateObject("WScript.Shell")

Set colProcesses = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!" & strComputer & "\root\cimv2").ExecQuery("Select * from Win32_Process Where Name = " & strProcessKill)
For Each objProcess in colProcesses

Return = objProcess.GetOwner\(strNameOfUser\)

If strNameOfUser = "SYSTEM"  Then
Wscript.Echo "Object " & strProcessKill & " Can't be deleted owned by " & strNameOfUser & VBNewLine
  
Else 
Wscript.Echo "Process " & objProcess.Name & " is owned by " & " \\ " & strNameOfUser & " on Machine " & strComputer & "."
nRunTime = datediff\("s",WMIDateStringToDate\(objProcess.CreationDate\), Now\)
if nRuntime > nMaxRunTime Then 

strCommand = "taskkill /F /IM " & objProcess.Name 

WshShell.Run strCommand,0,TRUE
intCount = intCount + 1

End If
End If

Next
If intCount > 0 Then
'Dim fso, txtFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set txtFile = fso.OpenTextFile(logPath, 8)

txtFile.WriteLine("===========================================" & VBNewLine & VBNewLine & Date & " - " & Time & " Killed " & intCount & strProcessKill & " processe(s) which were running by" & strNameOfUser & " on Machine " & strComputer & ".")

End If

But i am getting error that Unable to wait for a process (WshShell.Run)

---------- Post updated at 09:23 PM ---------- Previous update was at 09:20 PM ----------

The problem is i am trying to kill a session if it exceeds some particular timings in 64 bit server., i am not able to do it., tried objProcess.Terminate() method (its working for few components like notepad,excel etc but not for SAS components) ., so i thought of using taskkill function ., but even here i am getting problems. Any help would be much appreciated.