I want to terminate a process by its process id. I have tried with openprocess() & terminateprocess(). But its not working. I am giving u the code which i tried.

Dim processid As Long
Dim processhandle As Long
Dim lExitCode As Long
processid = Shell("C:\winnt\system32\notepad.exe", vbMinimizedFocus)

processhandle = OpenProcess(PROCESS_ALL_ACCESS, 0&, processid)
GetExitCodeProcess processhandle, lExitCode
TerminateProcess processhandle, lExitCode

Its not working bcos terminateprocess is taking processhandle(it becomes 0 as soon as it opens notepad.exe) , but i want to terminate the notepad.exe . How to do that? Can u help me in this regard?