简体   繁体   English

当经典ASP使用时,如何终止WINWORD.EXE?

[英]How do I terminate WINWORD.EXE when used by classic ASP?

I have a user who has to use Microsoft Word 2007 to create and manipulate word documents in his ASP web application. 我有谁有权使用Microsoft Word 2007中创建和操纵他的ASP Web应用程序Word文档的用户。 I'm well aware of the ' Considerations for server-side Automation of Office ' KB article and the many third party components available to do this kind of thing, but they've gone a fair bit down this road already. 我非常了解“ 有关服务器端Office自动化的注意事项 ”的知识库文章,以及许多可用于执行此类操作的第三方组件,但是他们已经走了相当远的路。

The problem he's having is that the WINWORD.EXE process never terminates even though he calls Quit on the application object. 他遇到的问题是,即使他在应用程序对象上调用QuitWINWORD.EXE进程也不会终止。

For example: 例如:

Set objWord = Server.CreateObject("Word.Application")
'' Do work
objWord.Quit
Set objWord = Nothing

As you would expect, his server ends up littered with orphaned WINWORD.EXE processes requiring manual intervention to terminate. 如您所料,他的服务器最终到处都是孤立的WINWORD.EXE进程,需要手动干预才能终止。

Is there a way to terminate these WINWORD.EXE processes explicitly in the script? 有没有办法在脚本中显式终止这些WINWORD.EXE进程?

Update: 更新:

I've made some progress with this and I think I have a handle on what the problem is. 我已经在这方面取得了一些进展,我认为我可以解决问题所在。 When an Office application runs for the first time under a new Windows account it asks for your name and initials. 当Office应用程序在新的Windows帐户下首次运行时,它会要求您提供名称和缩写。 Now because there is no visible GUI, there is no-one there to push all the right buttons. 现在,由于没有可见的GUI,因此没有人可以按下所有正确的按钮。 I've tried starting WINWORD.EXE as the website anonymous account identity using RUNAS , but there's some permission issue that's preventing Word or Office performing some other kind of initial setup routine it wants to do. 我尝试使用RUNASWINWORD.EXE作为网站匿名帐户身份RUNAS ,但是存在一些权限问题,该问题阻止了Word或Office执行其想要执行的其他某种初始设置例程。

There are two things I can think of: 我可以想到两件事:

MyWorkBook .Saved has not been set to true. MyWorkBook .Saved尚未设置为true。 As a result the Quit call results in WinWord displaying a "Do you wish to save" dialog. 结果,退出呼叫将导致WinWord显示“是否要保存”对话框。 On a server. 在服务器上。 Under a session with no desktop. 在没有桌面的会话下。 Needless to say Word never manages to quit as it is waiting for the user. 不用说,Word在等待用户的过程中永远不会退出。

Your user's script is not always making it to the Quit line. 用户的脚本并不总是将其添加到“退出”行。 This is a frequent and perhaps biggest reasons against using the Office Automation, as you really need multiple layers of exception handling and finally statements (which isn't VBScript or the ASP classic engines strong point) to ensure that the instance is properly cleaned up. 这是使用Office Automation的常见原因,也许是最大的原因,因为您确实需要多层异常处理和finally语句(这不是VBScript或ASP经典引擎的强项),以确保正确清理实例。

This question is now no longer relevant. 现在,此问题不再相关。 Almost all the issues were related to WINWORD.EXE requiring elevated privileges (higher than we allow for web site anonymous user accounts) to be able to perform certain tasks. 几乎所有问题都与WINWORD.EXE有关, WINWORD.EXE需要更高的特权(高于我们对网站匿名用户帐户所允许的特权)才能执行某些任务。

Customer has wisely decided to use ASPOSE.Words for .NET which also has a COM callable wrapper so classic ASP code can use it too. 客户明智地决定使用ASPOSE.Words for .NET ,它也具有COM可调用包装器,因此经典的ASP代码也可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM