如何在 StartupTask 中为可执行文件指定参数 [英] How to specify parameters for the executable file in a StartupTask

查看:31
本文介绍了如何在 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

我在转换后的桌面应用程序中需要同样的东西.感谢 StartupTask,我能够在启动时运行应用程序的可执行文件:

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.

推荐答案

很遗憾,今天无法为启动任务指定参数.这是我们积压工作中的一个开放工作项.

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

正如您所指出的,一种可能的解决方法是启动一个不同的 EXE,然后以所需的模式启动您的应用.

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

谢谢!

这篇关于如何在 StartupTask 中为可执行文件指定参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆