I am using the code below to start ror server. Is there a easy way to quit that window without going through the route of finding the pid and using 'taskkill'? I mean after all i have the handle in 'shell' variable don't I?
shell = WIN32OLE.new('Shell.Application')
shell.ShellExecute("run_app_server.bat")
With the above code a window running ror server shows up. Now I also want to quit it from within the code.
Thanks
Well, you have a reference to an ole automation Shell object, but once you use ShellExecute to start a process in it's own window, that process belongs to Windows and I don't believe it's exposed in any way via the shell automation object - so there's no way to use an object reference to terminate it.
Rather than using Taskkill from a shell, though, you could also do the search & kill via automation like you're doing now - maybe adapt or "translate" this Perl script that does it.