在LAN连接的其他计算机上终止进程

编程入门 行业动态 更新时间:2024-10-08 10:58:04
本文介绍了在LAN连接的其他计算机上终止进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个程序,用于将文件从本地计算机发送到通过LAN连接的其他计算机(kiosk)。 如何终止特定流程?自助服务终端正在运行应用程序,但我想先终止程序并将文件(更新)发送到文件夹,就像文件分发一样。我尝试了一些代码,但它是异常的。下面是我尝试过的两个功能,但都没有工作。如果有什么我想念或错误,请提供协助。

Hi, I'm developing a program to send file from local computer to other computer(kiosk) which connected through LAN. How to terminate a specific process? The kiosk is running with application, though I want to terminate the program first and send file (update) to the folder just like file distribution. I have tried some code but it goes exception. Below are two function that I tried, but none working. Please assist if there is something that I miss or mistake.

Public Sub endprocess(ByVal RemotePC As String, ByVal process As String) Dim objWMIService As Object Dim colProcessList As Array Dim objprocess As Object Dim response As Boolean objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & RemotePC & "\root\cimv2") process = "'" & process & "'" colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = " & process) For Each objprocess In colProcessList response = MsgBox("End " & process & " on " & RemotePC & "?", MsgBoxStyle.YesNoCancel) If response = vbYes Then objprocess.Terminate() Else Exit Sub End If Next End Sub Private Function WMIKill(ByVal Server As String, ByVal sProcess As String) Try Dim scope As New ManagementScope("\\" & Server & "\root\CIMV2") Dim query As New ObjectQuery("SELECT * FROM Win32_Process WHERE Name = '" & sProcess & "'") Dim searcher As New ManagementObjectSearcher(scope, query) For Each queryObj As ManagementObject In searcher.Get() AppendTextBox(txtevents, "-----------------------------------") AppendTextBox(txtevents, "Win32_Process instance") AppendTextBox(txtevents, queryObj("Name")) AppendTextBox(txtevents, "-----------------------------------") Next Catch err As ManagementException AppendTextBox(txtevents, "An error occurred while querying for WMI data: " & err.Message) Catch unauthorizedErr As System.UnauthorizedAccessException AppendTextBox(txtevents, "Connection error (user name or password might be incorrect): " & unauthorizedErr.Message) End Try End Function

如果有人之前执行此功能,请分享。如何运行已经更新的应用程序?

And if someone does this function before, please share. How to run back the application that already updating?

推荐答案

您的方法存在缺陷,远程终止进程并不是发送更新应用程序的好方法。相反,您应该寻找Click Once Deployment。本文 ClickOnce - 快速部署,安装和更新基于Windows的步骤客户端应用程序 [ ^ ]可以帮助您提供良好的开端。 Well your approach has flaws, Terminating a process remotely is not a good solution to send updated applications. Instead you should look for Click Once Deployment. This article ClickOnce - Quick steps to Deploy, Install and Update Windows Based Client Applications[^] could help you giving a good start.

更多推荐

在LAN连接的其他计算机上终止进程

本文发布于:2023-10-16 14:06:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1497787.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:进程   其他计算机   LAN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!