如何以管理员身份和兼容模式自动运行VB6编译的软件
我们有一个用 VB6 构建的 ERP 应用程序,它运行得很好,直到我们的一些客户将他们的所有系统升级到 Win7。
该软件的编程方式是注册一些在运行时基于 COM 的插件(在插件文件夹中找到)。现在,当用户在未设置兼容模式和以管理员身份运行设置的情况下运行该软件时,它会失败并崩溃。
我知道我们可以通过右键单击程序可执行文件然后转到其属性来手动设置兼容模式以及运行管理员。但这看起来非常不专业。
我认为会有某种方法告诉Win 7自动以兼容模式和以管理员身份运行运行软件。
请帮我。
We have an ERP application which is built in VB6 and it was running just fine till a few of our customer upgraded all their systems to Win7.
This software is programmed in such a way that it registers a few plugins (found in plugin folder) which are COM based at runtime. Now when the software is run by user without setting Compatibility Mode and Run as Administrator setting it fails and crashes.
I know we can manually set both Compatibility Mode as well as Run a Administrator by right clicking on program executable and then going to its properties. But this looks very unprofessional.
I think there will be some way to tell Win 7 to automatically run a software in Compatibility Mode and Run as Administrator.
Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
兼容性是一项管理功能,而不是开发或部署功能。最好尽可能修复应用程序,尤其是消除任何海拔要求。
有很多工具可用于调查问题,以便您可以纠正它们。然而,在运行时全局注册“插件”是一件令人讨厌的事情。 VB6 组件自注册始终是全局的,除非注册表虚拟化可以对其进行重定向。为什么不为可以在安装过程中提升运行一次的插件创建安装程序?
有一些方法可以减少手动设置兼容性,即使作为安装的一部分 - 尽管微软不鼓励这样做。也许看看:
兼容性修复数据库管理策略和部署
然而,所需的精力最好花在修复问题上。随着时间的推移,支持成本将会减少。
Compatibility is an administrative function, not a development or deployment function. It is better to fix the application where possible, especially to remove any requirement for elevation.
There are plenty of tools for investigating the issues so you can correct them. However globally registering "plug ins" at runtime is a nasty one. VB6 component self-registration is always global unless registry virtualization can redirect it. Why not create installers for the plug-ins that can run elevated once during installation?
There are ways to set compatibility less manually, even as part of installation - though Microsoft discourages this. Maybe take a look at:
Compatibility Fix Database Management Strategies and Deployment
However the effort required might be better spent on remediating the problem. Support costs will be less over time.
正如其他答案所说,您不需要一直跑步。
如果您想在启动后注册插件(作为普通用户),您可以使用 ShellExecute() 和“runas”动词来运行 regsvr32.exe,或使用 COM 提升 已之前讨论过很多次。
As the other answers have said, you shouldn't need to run all the time elevated.
If you want to register the plugins after its started (as a normal user), you can use ShellExecute() with the "runas" verb to run regsvr32.exe, or use COM elevation which has been discussed many times before.
您可以通过在应用程序清单中指定应用程序必须以管理员身份运行,该清单位于您可以嵌入或随应用程序一起部署的 xml 文件中。
一旦您的应用程序以管理员权限运行,它应该能够注册并加载插件。您不需要以兼容模式运行来访问 COM 插件。
You can indicate that an application must run as admin by specifying it in the Application Manifest, which in an xml file that you can either embed or deploy with your application.
Once your application is running with admin rights it should be able to register and load the plugins. You should not need to run in compatibility mode to access the COM plugins.