应用程序在 Windows 资源管理器之前启动
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5091504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Application Start Before Windows Explorer
提问by jSherz
Some installation applications stop (or appear to stop) the normal windows booting. The computer starts, the user logs in and then the installation program starts before others (like Windows explorer).
某些安装应用程序停止(或似乎停止)正常的 Windows 启动。计算机启动,用户登录,然后安装程序先于其他程序启动(如 Windows 资源管理器)。
How can I replicate this behaviour in my own program?
如何在我自己的程序中复制这种行为?
E.g.
例如
- OS Boot
- Login
- The program runs, updates etc.
- The rest of the programs run (e.g. windows explorer and what ever runs on startup)
- 操作系统启动
- 登录
- 程序运行、更新等。
- 其余程序运行(例如 Windows 资源管理器和启动时运行的程序)
采纳答案by Robert
I have not tried it but I assume that this is done by the registry entry
我还没有尝试过,但我认为这是由注册表项完成的
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup
There are even more registry keys - see the complete list documented here: Definition of the RunOnce Keys in the Registry
还有更多的注册表项 - 请参阅此处记录的完整列表: 注册表中 RunOnce 键的定义
But for your use case I would recommend to start your application as desktop shell similar to the proposed solution by "vcsjones". When your program has finished you can call explorer.exe
to start loading the regular desktop.
但是对于您的用例,我建议将您的应用程序作为桌面 shell 启动,类似于“vcsjones”提出的解决方案。程序完成后,您可以调用explorer.exe
开始加载常规桌面。
回答by vcsjones
If you want to start an application before the shell starts, you can add a value to the Userinit
value in the registry. In this key:
如果要在 shell 启动之前启动应用程序,可以Userinit
向注册表中的值添加一个值。在这个键中:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
There is a value named Userinit
. Change it so your program is run before userinit.exe. For example, to start notepad before the shell/everything else is initialized:
有一个名为 的值Userinit
。更改它以便您的程序在 userinit.exe 之前运行。例如,要在 shell/其他所有东西初始化之前启动记事本:
C:\WINDOWS\system32\notepad.exe,C:\Windows\system32\userinit.exe
C:\WINDOWS\system32\notepad.exe,C:\Windows\system32\userinit.exe
Use commas to separate the programs that should be started.
使用逗号分隔应该启动的程序。
This works for Windows XP, Vista, and 7.
这适用于 Windows XP、Vista 和 7。
回答by the JinX
You could possibly wrap a windows batch file .bat
around explorer.exe
你能不能换一个windows批处理文件.bat
身边explorer.exe
@echo off
something.exe
explorer.exe
But that wouldn't really make sure it's always started before explorer.exe
但这并不能真正确保它总是在 explorer.exe 之前启动
You could possibly change some registry value to select another 'shell' instead of explorer for that . .
您可能会更改某些注册表值以选择另一个“外壳”而不是资源管理器。.
If that is what you are actually looking for.
如果这就是您真正要寻找的东西。
回答by Simon Mourier
You should have a look at Windows Task Scheduler. Tasks can be scheduled to execute when a user (specific or any) logs on. The UI provided out-of-the-box by Windows illustrates what can actually be done with this standard Windows feature.
您应该看看 Windows任务计划程序。可以安排任务在用户(特定或任何)登录时执行。Windows 提供的开箱即用的 UI 说明了使用此标准 Windows 功能可以实际完成的工作。
Another solution is to write a Windows service(the .msi Windows Installer is in fact a service).
另一种解决方案是编写一个Windows 服务(.msi Windows Installer 实际上是一个服务)。
I'm not sure you will be able to blockWindows Explorer though...
不过,我不确定您是否能够阻止Windows 资源管理器...