从 ASP.NET 代码隐藏在服务器上启动进程并使其在服务器桌面上可见

发布于 2024-08-03 21:15:16 字数 730 浏览 2 评论 0原文

我的台式计算机上运行一个程序,该程序使 WCF 服务可用。这是我以普通用户身份登录时运行的常规 Windows 窗体应用程序。

我把WCF接口放进去,这样我就可以从外部网页看到程序的状态。这很好用,我可以看到正在运行的程序的状态,甚至可以根据需要更改内容。

我唯一不能做的就是启动程序。如果我访问网页并且程序运行,我希望能够启动它。一个简单的 Process.Start(programEXE) 是不够的,因为当程序启动时,它不在桌面上,我看不到它,尽管它确实显示在任务管理器中。

我尝试创建凭据并使用这些凭据启动程序,但它退出时出现非常模糊的“程序无法启动”错误,或者使用我的凭据启动但仍然没有显示在桌面上。在后一种情况下,我在任务管理器中以我的名字看到它,但没有看到实际的程序。

那么,如何在服务器上启动一个程序,该程序在已登录用户的桌面上可见(只有一个用户,并且该用户始终处于登录状态)?

另外,我可以采取哪些措施来确保这不会成为安全漏洞?我的一个想法是在它自己的虚拟目录中运行 launcher.aspx,其用户 ID 只具有对 program.exe 所在目录的读取权限,并且没有其他读取或写入权限。还有其他建议吗?

最后,需要明确的是:我没有尝试在用户计算机上启动任何内容。单击“启动程序”链接应在网络服务器上启动一个程序,而不是在客户端计算机上,并且该程序应该对服务器上的登录用户可见。强>。

I have a program running on my desktop machine that makes a WCF service available. This is a regular Windows Forms application that I run when logged in as a normal user.

I put the WCF interface in so that I could see the status of the program from an external web page. This works great, I can see the status of the running program and even change things as I see fit.

The only thing I can't do is start the program. If I go to the web page and the program is not running, I'd like to be able to start it. A simple Process.Start(programEXE) doesn't suffice because while the program starts, it is not on the desktop and I can't see it, though it does show up in Task Manager.

I tried creating credentials and launching the program with those credentials, but it exits with a very vague "Program failed to start" error, or starts with my credentials but still doesn't show up on the desktop. In the latter case, I see it in Task Manager under my name, but don't see the actual program.

So, How do I start a program on the server, visible on the desktop of the logged-in user (There's only one user and that user is always logged in)?

Also, what are some things that I can do to ensure that this doesn't become a security hole? One thought I had was to run the launcher.aspx in its own virtual directory, under a userid that only has read permissions to the one directory where program.exe is located, and has no other read or write permissions. Any other suggestions?

Finally, just to be clear: I am not trying to launch anything on the user's computer. Clicking on the "launch program" link should launch a program on the web server and not on the client machine, and that program should be visible to the logged-in user on the server.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟凡古楼 2024-08-10 21:15:16

我几乎可以肯定你不能这么做。您的 IIS 作为服务运行,并且没有与其关联的特定桌面环境。您尝试做的事情在网络/服务器环境中并不真正有效。

我建议您将 win 表单应用程序更改为 Windows 服务,然后您就可以通过网站启动/停止它。如果您使用 Windows 服务启用“与桌面交互”,那么我认为您可以使用 form.Show() 将应用程序带到当前用户的桌面环境。

如果您是唯一需要运行 winform 应用程序的人,那么为什么不自己启动该应用程序呢?您声明它可能永远不会被除您自己的计算机以外的任何计算机使用,因此当您可以通过快捷方式启动winform应用程序时,这似乎是访问本地网站来启动本地winform应用程序的复杂方法。

I'm almost positive that you can't do that. Your IIS runs as service and does not have a specific desktop environment associated with it. What you're trying to do doesn't really work in the web/server environment.

I'd recommend that you change your win form app to a windows service and then you'd be able to start/stop it via web site. If you enable "interact with desktop" with the windows service then I think you'd be able to have a form.Show() bring the app to the current user's desktop environment.

If you are the only person that needs to run the winform app, then why not just start the app yourself? You state that it'll probably never be used by any computer other than your own computer, so it seems like a complicated method of accessing a local web site to start a local winform app when you could just start the winform app via shortcut.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文