spersad Posted February 2, 2009 Share Posted February 2, 2009 Can anyone help me please. I would like to kill the Winword.exe process before I open it and write data to the document Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/ Share on other sites More sharing options...
rhodesa Posted February 2, 2009 Share Posted February 2, 2009 This describes how to kill processes with the command line: http://www.tech-recipes.com/rx/446/xp_kill_windows_process_command_line_taskkill/ try running that with PHP's exec() function Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752729 Share on other sites More sharing options...
Maq Posted February 2, 2009 Share Posted February 2, 2009 Use the shell execution function: shell_exec("killall Winword.exe"); You're going to have to explain the rest of your problem in more detail. Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752768 Share on other sites More sharing options...
spersad Posted February 2, 2009 Author Share Posted February 2, 2009 Thanks for the Help. I am basically creating a word object using the COM classes. EG. $word = new MSWordClass(); $word->Open($template_file); The problem is that when I run the application it takes a long time to generate the word document and when i check the list of processes in taskmanager, I see several instances of WINWORD.exe active. So I was thinking If i kill any active instances of WINWORD.exe before I run the above lines of code then my problem should be solved. What do you all think ? Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752774 Share on other sites More sharing options...
premiso Posted February 2, 2009 Share Posted February 2, 2009 Are you closing the $word object? Or does it have an option to close? It sounds like you are not properly closing that object, which is why the process keeps running. Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752775 Share on other sites More sharing options...
spersad Posted February 2, 2009 Author Share Posted February 2, 2009 As far as possible i have closed the object with these lines of code $word->Close(); $word->Quit(); $word = NULL; unset($word); Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752778 Share on other sites More sharing options...
premiso Posted February 2, 2009 Share Posted February 2, 2009 Not sure how that come object works, but I would do Quit before Close and see if that helps you at all. Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752779 Share on other sites More sharing options...
rhodesa Posted February 2, 2009 Share Posted February 2, 2009 the php doc has an example on opening word, creating a document, writing to it, and closing it. it's example # 1 here: http://us2.php.net/manual/en/class.com.php Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-752786 Share on other sites More sharing options...
spersad Posted February 3, 2009 Author Share Posted February 3, 2009 So far the exec("taskkill /IM WINWORD.exe"); seems to work. I will do futher testing and I will post my findings. Thanks for the help everyone Quote Link to comment https://forums.phpfreaks.com/topic/143496-how-to-kill-winwordexe-process-using-php/#findComment-753441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.