admin管理员组文章数量:1405370
I created an app for Windows in C#, which automatically starts when Windows starts.
I Write a simple key in the registry:
private bool autorunProperty;
private readonly static string registryString = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
private void CheckRegistryKey()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryString, true))
{
if (key != null)
{
object value = key.GetValue(appName);
if (value != null)
{
autorunProperty = true;
}
else
{
autorunProperty = false;
}
}
key.Close();
}
}
It works perfectly: reading and writing in the registry.
To distribute it I used "MSIX packaging for Visual Studio" and after test installation, doesn't write in the registry.
What I can do?
I created an app for Windows in C#, which automatically starts when Windows starts.
I Write a simple key in the registry:
private bool autorunProperty;
private readonly static string registryString = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
private void CheckRegistryKey()
{
using (RegistryKey key = Registry.CurrentUser.OpenSubKey(registryString, true))
{
if (key != null)
{
object value = key.GetValue(appName);
if (value != null)
{
autorunProperty = true;
}
else
{
autorunProperty = false;
}
}
key.Close();
}
}
It works perfectly: reading and writing in the registry.
To distribute it I used "MSIX packaging for Visual Studio" and after test installation, doesn't write in the registry.
What I can do?
- 1 "Apps that are packaged using MSIX can be configured to run in a lightweight app container. The app's process, and its child processes, run inside the container, and are isolated using file system and registry virtualization. For more info, see MSIX AppContainer apps. All AppContainer apps can read the global registry. An AppContainer app writes to its own virtual registry and application data folder, and that data is deleted when the app is uninstalled or reset. Other apps don't have access to the virtual registry or virtual file system of an AppContainer app." - MSDN – Gerry Schmitz Commented Mar 8 at 18:59
1 Answer
Reset to default 0I discovered the problem.
For security reasons, MSIX is designed to not allow writes to the run key and also prevents the use of the startup folder.
Microsoft introduced "StartupTask" Class to be used in the "Package.appxmanifest" file.
With a few lines of XML it is solved, as in the example:
<Applications>
<Application Id="App"
Executable="MyApp.exe"
EntryPoint="Windows.FullTrustApplication">
<Extensions>
<uap5:Extension Category="windows.startupTask">
<uap5:StartupTask
TaskId="LaunchOnStartupTaskId"
DisplayName="MyApp"/>
</uap5:Extension>
</Extensions>
https://www.advancedinstaller/startup-programs-msix.html
https://nicksnettravels.builttoroam/launch-on-startup/
The management of the App is delegated to the specific section of the control panel: Apps > Startup
本文标签: cUsing MSIX packaging for Visual StudioApp doesn39t write in registryStack Overflow
版权声明:本文标题:c# - Using MSIX packaging for Visual Studio, App doesn't write in registry - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744892625a2630875.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论