Windows 启动后 WPF 应用程序未启动
我的应用程序在 Windows 启动后不会启动,该应用程序已在注册编辑器中使用我的应用程序 exe 的正确路径进行注册。
这是我的代码,用于将我的应用程序注册到
private void OnViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RUN", true);
if (e.PropertyName == nameof(isStartOnStartup))
{
if (isStartOnStartup)
{
reg.SetValue("CommunicationHub", Process.GetCurrentProcess().MainModule.FileName);
Settings.Default.Startup = true;
Settings.Default.Save();
}
else
{
reg.DeleteValue("CommunicationHub");
Settings.Default.Startup = false;
Settings.Default.Save();
}
}
}
我已检查 EventViewer 的 注册编辑器崩溃并添加了日志记录到应用程序根目录,两者都没有给我任何帮助。
我已经禁用了UAC,检查是否是管理员权限阻碍了应用程序的运行,仍然没有结果。
我感到失落,我希望有人能帮助我解决这个问题。
My Application will not launch after Windows startup, the application is registered in the register editor with the right path to my application exe.
here is my code to register my application to the register editor
private void OnViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RUN", true);
if (e.PropertyName == nameof(isStartOnStartup))
{
if (isStartOnStartup)
{
reg.SetValue("CommunicationHub", Process.GetCurrentProcess().MainModule.FileName);
Settings.Default.Startup = true;
Settings.Default.Save();
}
else
{
reg.DeleteValue("CommunicationHub");
Settings.Default.Startup = false;
Settings.Default.Save();
}
}
}
I have checked EventViewer for crashes and have aswell added logging to the application root, both gave me nothing.
I have disabled UAC, to check if it was the administrator right that was hindering the application from running, still no result.
i feel lost, i hope someone can help me with the problem..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了另一种方法,而不是将我的应用程序放在寄存器编辑器中,但是在任务计划中,它将在Windows启动上启动使用Admin权利的应用程序。但!只有我告诉任务调度程序将其启动为“登录“触发”而不是“在系统启动”上。但是,如果我组合
td.triggers.addnew(tasktriggertype.boot);
和td.principal.userid =“ System”;
>它将使我的状态运行,但UI未显示。为什么?..如何解决此问题?
这是我的更新代码,我找到了一个可以完成计划的库。
库: https://github.com/dahall/taskscheduler
Found another way to do this, instead of having my application in the register editor, but in Task Schedular, it will launch the application on windows startup with the admin rights. BUT! Only if I tell task scheduler to launch it as "at log on" trigger and not on "at system startup". But if I combine
td.Triggers.AddNew(TaskTriggerType.Boot);
andtd.Principal.UserId = "SYSTEM";
it will give me the status running but the UI is not showing. Why?.. How do I fix this?
Here is my updated code, and I found a library to do the schedular thing.
library: https://github.com/dahall/TaskScheduler