安装ClickOnce而不运行

rjr*_*son 9 vb.net deployment clickonce

安装ClickOnce应用程序时,程序将在安装后运行.是否可以在运行的情况下安装?

我知道我可以使用安装和部署项目并创建安装程序,但我更喜欢使用ClickOnce.

Mag*_*son 8

要在安装后禁用自动启动,您只需禁用URL激活,如MSDN文章如何:禁用ClickOnce应用程序的URL激活(使用工具MageUI.exe)中所述.

禁用应用程序的URL激活

  • 选择"部署选项"选项卡.

  • 清除安装后自动运行应用程序复选框.

  • 保存并签署清单.


Mat*_*ton 3

我猜你可以假装它。引入一个“IsInstalled”布尔属性,默认为 false。然后在 Program.cs 中,将 Main() 方法更改为如下所示:

[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    if (!Properties.Settings.Default.IsInstalled)
    {
        Properties.Settings.Default.IsInstalled = true;
        Properties.Settings.Default.Save();

        MessageBox.Show("Install Complete");
        return;
    }

    Application.Run(new Form1());
}
Run Code Online (Sandbox Code Playgroud)

因此,现在,当应用程序首次安装时,它会检查该属性并简单地向用户显示一条消息,然后退出。

如果您想变得棘手,那么您可以查看解析部署的激活 URI,并使用一个 URI 参数来指定程序是否应该在首次安装时运行,或者只是静默关闭。

  • 它为什么首先运行应用程序? (4认同)