From: "Jon A. Lambert" Date: 2005-04-27T14:53:21+09:00 Subject: Re: Starting and stopping a child process in Windows Jon A. Lambert wrote: > You might use CreateProcess from Win32api. > The PID is returned in the last parameter, the process_information > structure. > Then use that PID in calling OpenProcess to get the Handle to use > when calling TerminateProcess. Here's a bit of code that partly works. That is it does get the process id. You'd have to look up all the actual values in the windows headers for the options you want. require 'Win32API' createProcess = Win32API.new("kernel32.dll","CreateProcess",'pplllllppp','L') startupinfo = [ 68 ].pack("lx64") procinfo = [ 0,0,0,0 ].pack("llll") createProcess.call(nil,"write.exe", 0, 0, 1, 0, 0, "c:\\apps", startupinfo, procinfo) processid = procinfo.unpack("llll")[2] puts processid # works up to here openProcess = Win32API.new("kernel32.dll","OpenProcess",'lll','L') handle = openProcess.call(0, 0, processid) puts handle terminateProcess = Win32API.new("kernel32.dll","TerminateProcess",'ll','L') terminateProcess.call(handle, 0)