JasonWei512 / EnergyStarX

🔋 Improve your Windows 11 device's battery life. A WinUI 3 GUI for https://github.com/imbushuo/EnergyStar.
https://www.microsoft.com/store/productId/9NF7JTB3B17P
GNU General Public License v3.0
906 stars 19 forks source link

Run as admin at startup / 以管理员身份开机自启 #4

Closed JasonWei512 closed 1 year ago

JasonWei512 commented 1 year ago

The problem you want to solve / 你想要解决的问题

Currently Energy Star X runs without admin privileges at startup, which means it cannot throttle those programs that run with admin privileges.

目前 能源之星X 开机自启时是以非管理员权限运行的。这导致无法限制那些以管理员权限运行的程序的资源。

Possible solution / 可能的解决方法

Register a Windows service. I am not sure whether a packaged WinUI 3 app supports this now.

注册一个 Windows 服务。我不确定一个打包 WinUI 3 应用现在支不支持这个。

Additional context / 其他信息

No response

xgdgsc commented 1 year ago

最近遇到睡眠唤醒后进程退出,是这个原因吗

JasonWei512 commented 1 year ago

The snipping tool Snipaste does this by creating a schedule task. However since MSIX package format doesn't allow developers to hook uninstalling process, after uninstalling Snipaste, the schedule task is still in Task Scheduler.

Relative issue: https://github.com/microsoft/WindowsAppSDK/discussions/3061

uJZk commented 1 year ago

所以如何静默启动呢,我想手动添加到计划任务里?

JasonWei512 commented 1 year ago

所以如何静默启动呢,我想手动添加到计划任务里?

创建一个以管理员身份开机时运行的计划任务,执行文件是: C:\Users\你的用户名\AppData\Local\Microsoft\WindowsApps\EnergyStarX.exe

等以后有时间会把这个功能加入应用中。

JasonWei512 commented 1 year ago

差不多基本做完了。需要测试个几天。 分支: https://github.com/JasonWei512/EnergyStarX/tree/feature/run-at-startup-as-admin CI 编译的包: https://github.com/JasonWei512/EnergyStarX/actions?query=branch%3Afeature%2Frun-at-startup-as-admin

Almost finished. Need several days to test.

JasonWei512 commented 1 year ago

Will be shipped in 1.0.3 this weekend. 会在这周末的 1.0.3 版本中发布。