Process.kill()无法在服务器中工作 [英] Process.kill() not working inserver

查看:105
本文介绍了Process.kill()无法在服务器中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否有其他方法可以使用vb.net杀死一个进程?

我已经尝试了process.Kill()方法,它在我当地工作正常但是在服务器上进行测试时,它无法正常工作,并且流程仍然在后台。

您有什么建议吗?



< b>我尝试了什么:



Hi, I would like to ask if there any other methods to kill a process using vb.net?
I have tried the process.Kill() method and it is working fine in my local but upon testing it in server, it isn't working and the processes remains in background.
Do you have any suggestion?

What I have tried:

Public Sub CreateNew_Word(ByVal strResult As List(Of String))

'Added Code
'Description:Get all running winword processes then stored it in the list
        Dim processIds As New List(Of Integer)()
       For Each process__1 As Process In Process.GetProcessesByName("winword")
            processIds.Add(process__1.Id)
        Next

'***WORD FILE GENERATION HERE****

'Remove clean-up code to test the killing of process
'ReleaseObject(rng)
'newDoc.Close(False)
'ReleaseObject(newDoc)

'WordApp.Application.Quit(False)
'ReleaseObject(WordApp)

'GC.Collect()
'GC.WaitForPendingFinalizers()
'GC.Collect()
'GC.WaitForPendingFinalizers()

'Description: As the existing processes has been stored in the list. Those processes will not be killed. Only the generated winword.exe will be killed because it is not inside the list.
        For Each process__1 As Process In Process.GetProcessesByName("winword")
            If Not process__1.HasExited AndAlso Not processIds.Contains(process__1.Id) Then
                process__1.Kill()
            End If
        Next

推荐答案

如果这是一个ASP.NET或Windows服务应用程序,您不能使用Word。非用户交互式环境中不支持任何Office应用程序。
If this is an ASP.NET or a Windows Service application you can NOT use Word. None of the Office applications are supported in a non-user interactive environment.


当您在本地计算机上运行代码时,它可能在您自己的帐户下运行,因此它有权杀死流程。在服务器上,它在没有这些权限的帐户下运行。此外,asp.net自动化也不支持Word,这就是为什么你看到流程出现问题导致问题的原因。


你已经被告知这个是不会工作(现在你找到原因)并使用其他一些管理Word文档的方法。
When you run the code on your local machine it is probably running under your own account so it has the rights to kill processes. On the server it is running under an account that doesn't have these permissions. Also Word is not supported for asp.net automation which is why you're seeing the problems you are with processes hanging around causing problems.

You have already been told this isn't going to work (now you're finding out why) and to use some other method of managing Word documents.


这篇关于Process.kill()无法在服务器中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆