1

I'm new to MAUI and I'm making an application where I need to make the app run on startup on windows. I did this before on Winform/WPF using things like registry records, adding a shortcut to shell:startup, or even from the installer file (like Inno setup).

Obviously, I can't use anything from above with MAUI as I don't have an EXE file or even able to get the executable directory.

MAUI is still new and there were no useful results when I searched.

Even a script that I can maybe add to a Task Scheduler would be helpful at this point as I can create a task for it but I need to know how to run an app on windows that is installed from the windows store. Thanks.

Edit: Whenever I try to run the EXE file from windows build I get this error from the event viewer

Faulting application name: MAUIApp1.exe, version: 1.0.0.0, time stamp: 0x6331eb0e
Faulting module name: KERNELBASE.dll, version: 10.0.22621.608, time stamp: 0x4769d08d
Exception code: 0xe0434352
Fault offset: 0x000000000008fb0c
Faulting process id: 0x0x5670
Faulting application start time: 0x0x1D8EE46B08192B8
Faulting application path: D:\CrossPlatform\MAUIApp1\MAUIApp1\bin\Debug\net6.0-windows10.0.19041.0\win10-x64\MAUIApp1.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 395637f8-d737-4ae3-8443-da7889494026
Faulting package full name: 
Faulting package-relative application ID: 
  • a MAUI windows app is just a normal UWP/WinUI app, and you should be able to use any of the packaging tools to create an executable – Jason Nov 01 '22 at 22:38
  • 1
    @Jason the EXE created by MAUI project can't run, I'm only able to debug it or publish it as an MSIX package. If I clicked the EXE file nothing happened. – Abanoub Zak Nov 01 '22 at 23:04
  • 1
    Right; the EXE is not useful. Does this answer your question? [How to Auto Start An Application which is packaged using Msix?](https://stackoverflow.com/questions/62780861/how-to-auto-start-an-application-which-is-packaged-using-msix) – ToolmakerSteve Nov 01 '22 at 23:55

1 Answers1

0

Thanks to ToolmakerSteve comment I figured out how to make it. I still prefer doing it from the code as it gives me more control, but at least I can make it start with windows now.

I'm leaving the direct solution here for anyone in the future coming to look for it.

Under platform>Windows open Package.appxmanifest with a notepad or any text editor.

enter image description here

Inside Applications, tag add the following code

 <Extensions>
          <uap5:Extension
            Category="windows.startupTask"
            Executable="YOURAPPNAME.exe"
            EntryPoint="Windows.FullTrustApplication">
            <uap5:StartupTask
              TaskId="MyStartupId"
              Enabled="true"
              DisplayName="YOURAPPNAME" />
          </uap5:Extension>
        </Extensions>

Should be like this

enter image description here

Enabled="true" make the star on startup enabled by default.

Enabled="false" still add the app to the startup list, but the user needs to go enable it from Task Manager himself/herself.

Next, add this line to the top inside the Package tag

xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"

Now save it then start your solution again then run your app or publish it, once the app starts it will be added to the startup list.