从 C# 启动远程进程的问题
我正在使用 System.Diagnostics.Process.Start 启动远程另一台域计算机上的应用程序。
不幸的是,如果远程进程已经在运行,但在远程计算机桌面的后台,则应用程序无法使用 Process.Start 获得焦点。
问题1:是否有其他API或机制可以强制远程应用程序获得焦点或闪烁以引起用户的注意?
我注意到的另一个问题是,如果远程进程已经在运行,除了原始实例之外,还可能会执行一个新实例。这违反了 MSDN 的文档:
“如果进程已经在运行,则不会启动额外的进程资源。相反,会重用现有的进程资源,并且不会创建新的进程组件。在这种情况下,Start 返回 null,而不是返回新的进程组件到调用过程。”
问题 2: 有没有人找到一种方法来防止在这种情况下启动应用程序的第二个实例? WMI 是远程启动应用程序的更好选择吗?
I'm using System.Diagnostics.Process.Start to launch a remote application on another domain machine.
Unfortunately, if the remote process is already running, but in the background of the remote machine's desktop, the application does not gain focus using Process.Start.
Question 1: Is there another API or mechanism to force the remote application to gain focus, or flash to get the user's attention?
The other issue I noticed, is if the remote process is already running, a new instance may be executed in addition to the original. This violates MSDN's documentation which says:
"If the process is already running, no additional process resource is started. Instead, the existing process resource is reused and no new Process component is created. In such a case, instead of returning a new Process component, Start returns null to the calling procedure."
Question 2: Has anyone found a way to prevent a second instance of the application from launching in this case? Is WMI a better choice to use for remote launching of applications?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,不知道这对您来说效果如何,但它是您可以在帮助程序中使用的示例类。这只是开始,如果您打算使用它,您将需要一个网络系统(尽管使用 C# 也不错)。告诉我它对你有什么作用。
Well, don't know how well this will work for you, but it is an example class that you could use in the helper program. This is only the start, if you plan on using it, you will need a networking system (not to bad with C# though). Tell me how it works for you.