在启动安装程序之前检查 Windows 更新或任何安装程序实例是否正在运行(java)

发布于 2025-01-02 02:09:41 字数 166 浏览 0 评论 0原文

想要在开始安装之前检查我的安装程序是否正在运行任何其他安装。就像我想检查 Windows 更新或任何其他安装程序是否正在运行一样,我不会启动我的安装程序。

我计划检查是否有任何 msiexec 实例正在运行。有没有更好的方法,检查 Windows 更新是否相同。仅供参考,我的安装程序是用java编写的

want to make a check in my installer before starting installation if any other installation is running beforehand. Like I want to make a check if windows update or any other installer is running i'll not start my installer.

I'm planning to check if any msiexec instance is running before hand. Is there any better approach, and will that be same for checking windows update. FYI my installer is in java

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

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

发布评论

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

评论(4

空‖城人不在 2025-01-09 02:09:41

您应该知道,安装完成后,msiexec.exe 仍将运行几分钟。这是操作系统中的默认行为,它使进程保持活动状态几分钟,以防用户开始另一个安装,以节省重新启动的时间。因此检查进程可能会提供不正确的数据。

另外,如果您的安装程序是用 Java 编写的,您能否解释一下为什么需要检查 msiexec.exe 进程?

You should know that msiexec.exe will still be running for a couple of minutes after an installation is finished. This is a default behavior in the OS, it keeps the process alive for a couple of minutes, in case the user will start another installation, to save time from starting it all over again. So checking for the process could give you incorrect data.

Also, if you have your installer written in Java can you please explain why do you need to check for msiexec.exe processes?

你另情深 2025-01-09 02:09:41

由于您的安装程序是用 Java 编写的,因此我认为没有理由检查其他安装程序是否正在运行,而且没有可靠的方法来执行此操作。

您的安装程序是否尝试替换系统文件?不应该。
您的安装程序是否尝试更新正在使用的文件?它必须优雅地做到这一点。并要求用户关闭有问题的应用程序;如果不可能或用户不想立即关闭应用程序,安装程序会在完成安装后要求用户重新启动系统。

在没有其他安装程序运行的情况下,有太多的事情需要关心。这就是为什么使用专门的安装工具更为明智。

Since your installer is in Java, I see no reason to check whether other installers are running, moreover there's no robust way to do so.

Does your installer try to replace system files? It should not.
Does your installer try to update a file in use? It must do it gracefully. And ask user to close an offending application; if it's not possible or user does not want to close the application right away, your installer asks user to restart the system when it completed installation.

Too much to care about, without other installers running. That's why it's wiser to use a specialized installer tool.

薄荷→糖丶微凉 2025-01-09 02:09:41

要检查操作系统是否正在进行安装,可以使用以下注册表项:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress

请注意,Windows Installer 不允许同时执行多个 InstallExecuteSequences ,但是您可以从不同的包启动多个安装 UI。通常在您按下“安装”并授予启动系统更改(创建注册表、复制文件等)的所有权限时,程序包就会进入InstallExecuteSequence。

在这里您可以找到有关 InstallUISequence 和 InstallExecuteSequence 的更多信息:
http://msdn.microsoft。 com/en-us/library/windows/desktop/aa372404(v=vs.85).aspx

To check the OS for installations in progress you can use the following registry entry:

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress

Please note that Windows Installer does not allow multiple InstallExecuteSequences to be executed simultaneously, however you can launch multiple installation UIs from different packages. The package enters InstallExecuteSequence usually at the moment you press "Install" and grant all the permissions for starting the system changes (creating registry, copying files, etc...).

Here you can find more information about InstallUISequence and InstallExecuteSequence:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa372404(v=vs.85).aspx

画离情绘悲伤 2025-01-09 02:09:41

谢谢你们的建议,我最终决定创建一个 Windows 本机 dll 来检查 WindowsInstaller 的状态。如果返回的 SERVICE_STATUS_PROCESS 结构的 dwControlsAccepted 成员的值为 SERVICE_ACCEPT_SHUTDOWN,则 Windows Installer 服务当前正在运行。然后使用 JNI 从我的 java 类中调用它。

Thank u guys for your suggestions, I final decided to go with creating a windows native dll to check the status of WindowsInstaller. The Windows Installer service is currently running if the value of the dwControlsAccepted member of the returned SERVICE_STATUS_PROCESS structure is SERVICE_ACCEPT_SHUTDOWN. Then used JNI to to call it from my java class.

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