Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C“启动时应用程序未运行,启动影响”;“未测量”;在Windows 10上_C#_Wpf - Fatal编程技术网

C# C“启动时应用程序未运行,启动影响”;“未测量”;在Windows 10上

C# C“启动时应用程序未运行,启动影响”;“未测量”;在Windows 10上,c#,wpf,C#,Wpf,我有一个小的WPF应用程序。我正在尝试在Windows启动时启动它 我的C#代码如下: using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) { key.SetValue("MyApp", "\"" + System.Reflection.Asse

我有一个小的WPF应用程序。我正在尝试在Windows启动时启动它 我的C#代码如下:

using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
                {
                    key.SetValue("MyApp", "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\"");
                    key.Close();
                }
和已删除的注册表项:

using (RegistryKey key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
            {
                key.DeleteValue("MyApp", false);
                key.Close();
            }
我已经建立了一个可执行文件(MyApp.exe)并安装在我的计算机上。但当Windows启动时,应用程序仍然无法运行。我该怎么办?如何将“未测量”的启动影响更改为任务管理器上的其他影响

我使用的是Windows10x64。对不起我的英语


谢谢。

对于像我这样有问题的人,我已经解决了我的问题,就是我的应用程序需要以管理员身份运行,所以如果我按照上面的方式编码并设置app.manifest

<requestedExecutionLevel level = "requireAdministrator" UIAccess = "false "/>

下一个问题是如何关闭应用程序的UAC(如果计算机上启用了UAC),您可以看到。关于状态影响,即使任务管理器上的状态为“未测量”,应用程序仍将在窗口启动时运行。 谢谢

更新

您可以在windows启动时读取以运行应用程序,而无需添加注册表项,这对我很有用。

重复的
 using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
            {
                key.SetValue("TechTemp", "\"" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\"");
                key.Close();
            }
 using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
            {
                key.DeleteValue("TechTemp", false);
                key.Close();
            }