You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何实现Windows应用在开机/休眠恢复时为所有用户自动启动?

Solution for Auto-Running App for All Users on Startup & Wake from Sleep/Hibernation

Got it, let's work through this problem together. You need your application to launch automatically for every user on two occasions: when the system starts up after a shutdown, and when waking from sleep or hibernation. Your previous attempts with shell:startup and the HKLM Run registry key fell short because they didn't cover all users or the sleep/wake scenario—here's how to fix it:

1. Ensure All-User Startup (Post-Shutdown)

The HKLM Run registry key does work for all users, but you might have missed a critical detail in the command syntax. Let's get this right:

  • Open Command Prompt as Administrator
  • Run this command, replacing YourAppName with a unique identifier for your app and C:\Full\Path\To\YourApp.exe with the absolute path to your executable (wrap the path in quotes if it contains spaces):
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "YourAppName" /t REG_SZ /d "\"C:\Full\Path\To\YourApp.exe\"" /f
    
  • If you're running a 32-bit app on a 64-bit system, use this 32-bit registry path instead:
    REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" /v "YourAppName" /t REG_SZ /d "\"C:\Full\Path\To\YourApp.exe\"" /f
    

This ensures your app launches for every user when the system boots up. The nested quotes are essential—without them, the registry entry will fail if your path has spaces.

2. Trigger App on Sleep/Hibernation Wake

Registry Run keys only fire on system startup, not when waking from sleep. To cover this scenario, Task Scheduler is the most reliable tool—it lets you trigger actions on system wake and can be configured for all users:

Step-by-Step Task Setup

  1. Open Task Scheduler by searching for taskschd.msc in the Start Menu (run it as Administrator for full access).
  2. Click Create Task (skip "Create Basic Task"—we need advanced options).
  3. General Tab:
    • Name your task (e.g., "Launch My App on Wake")
    • Check Run whether user is logged on or not
    • Check Run with highest privileges (avoids UAC blocks that might prevent the app from launching)
    • Set the "Configure for" dropdown to your Windows version (e.g., Windows 10/11)
  4. Triggers Tab:
    • Click New
    • Under "Begin the task", select Workstation unlock (this triggers when any user wakes the system and unlocks it)
    • In the "Settings" section, select Any user to ensure this works for all accounts
    • Click OK to save the trigger
    • (Optional) Add a "At startup" trigger here too if you want to combine both startup and wake triggers in one task, instead of using the registry
  5. Actions Tab:
    • Click New
    • Under "Action", select Start a program
    • In "Program/script", browse to your app's executable or paste the full absolute path (use quotes if there are spaces)
    • Click OK
  6. Conditions Tab:
    • Uncheck Start the task only if the computer is on AC power if you want the app to launch even when on battery
    • Leave other options as default
  7. Settings Tab:
    • Check If the task fails, restart every [X] minutes (e.g., 5 minutes) to ensure the app launches successfully if there's a temporary issue
    • Check If the task is already running, then do not start a new instance to prevent duplicate app windows
    • Click OK to save the task

Key Notes to Avoid Issues

  • Store your app in a location accessible to all users (e.g., C:\Program Files\YourApp), not in a user-specific folder like Documents or Desktop.
  • Test both scenarios: shut down the system, boot up, log into different users to confirm the app runs; then put the system to sleep/hibernation, wake it, unlock, and verify the app launches.

内容的提问来源于stack exchange,提问作者Rocky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:44:29