将 CopyData 用于提升的应用程序的一个好的替代方案是什么
我有一个应用程序可以停止服务,复制文件,然后再次启动服务。我希望它显示一个进度条,没有额外的窗口,没有改变屏幕,只是让UAC做它的事情并从那里继续(它是一个配置程序,所以它仍然可以作为标准用户使用,副本上有盾牌图标按钮)。
它执行此操作的方式是,以管理员身份打开一个单独的应用程序(本身的另一个应用程序,使其不可见,就像 msiexec 所做的那样),然后新应用程序执行其操作并通过 SendMessage 发回进度报告。这工作正常,但事实证明 SendMessage 在管理/非管理应用程序之间只能以一种方式工作。重定向 StandardInput 不起作用,因为这需要关闭 ShellExecute,而“runas”需要打开 ShellExecute。
我不想使用文件,因为那样会很慢并且存在安全风险(我在包含之前命令的 CopyData 消息旁边发送了一个关键代码)。是否有另一种方法可以重定向标准输入/输出?微星是如何做到的?
我为此使用 C#。
I have an application that stops a service, copies a file, then starts the service again. I want it to display a progress bar and no extra window, no changing screens, just let the UAC do its thing and continue from there (it's a configuration program, so it is still usable as standard user, with the shield icon on the copy button).
The way it does this is by opening a separate application (another of itself, made invisible, like what msiexec does) as admin, then the new one does its thing and sends back progress reports through SendMessage. This works fine, but it turns out SendMessage only works one way between admin/non-admin applications. Redirecting StandardInput won't work, because that needs ShellExecute to be off, and "runas" needs ShellExecute to be on.
I don't want to use a file, because that would be slow and a security risk (I was sending a key code alongside the CopyData messages that contained the commands before). Could there be another way to redirect the StandardInput/Output? How does MSI do it?
I'm using C# for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我本来打算像西蒙那样建议使用管道。
不过,技巧之一是较高完整性进程需要创建管道并使用中等强制完整性级别对其进行标记,以便中等完整性进程可以访问它。
i was going to suggest pipes, as Simon did.
One of the tricks, though, is that the higher integrity process needs to create the pipe and tag it with the medium mandatory integrity level, so that your medium integrity process can access it.