Mehrzad Chehraz
Mehrzad Chehraz

Reputation: 5137

How to specify parameters for the executable file in a StartupTask

When desktop applications set to run on startup, they usually start minimized to system tray. The common approach to implement this behavior is an special parameter for the executable when adding a shortcut to the Startup folder or registry:

MyApp.exe /startminimized

I need the same thing in a converted desktop app. Thanks to the StartupTask, I'm able to run the executable of the app on startup:

<desktop:Extension
    Category="windows.startupTask"
    Executable="MyApp.exe"
    EntryPoint="Windows.FullTrustApplication">
    <desktop:StartupTask
        TaskId="MyStartupTask"
        Enabled="true"
        DisplayName="Some Arbitrary Name" />
</desktop:Extension>

However, I'm not able to find a way to set an argument for the executable so that my app knows it is running from startup and starts minimized.

I should be able start another executable which starts my app minimized but I'm looking for a more elegant approach to directly run the app minimized and keep the startup impact low.

Upvotes: 4

Views: 626

Answers (2)

Bogdan Mitrache
Bogdan Mitrache

Reputation: 10993

As Stefan mentioned, currently there is no native support for shortcut arguments but tools like Advanced Installer and others handle this stub (different EXE) behind the scenes, saving you some precious time.

Disclaimer: I work on the team building Advanced Installer.

Upvotes: 0

Stefan Wick  MSFT
Stefan Wick MSFT

Reputation: 13850

There is no way to specify a parameter for startup task today unfortunately. It is an open work item on our backlog.

As you point out, a possible work around is to launch a different EXE that then launches your app in the desired mode.

Thanks!

Upvotes: 3

Related Questions