How can I make a Click-once deployed app run at startup?

后端 未结 11 1752

How can I make a Click-once deployed app run a startup?

The best option I found by searching was to set the Publisher on the app to Startup, so the Start menu shortc

11条回答
  •  眼角桃花
    2020-12-04 22:44

    First off thanks for the answer Discdev. To get this to work with Å Ä Ö and other special characters this modification did it for me, using UTF-8 a different code page and no BOM.

    string[] mystrings = new string[] { "chcp 65001", @"IF EXIST ""%appdata%\Microsoft\Windows\Start Menu\Programs\\.appref-ms"" (""%appdata%\Microsoft\Windows\Start Menu\Programs\\.appref-ms"") ELSE (start /b """" cmd /c del ""%~f0""&exit /b)" };
    string fullPath = "%appdata%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\StartErrandDynamicMenu.bat";
    System.Text.Encoding utf8WithoutBOM = new System.Text.UTF8Encoding(false);
    System.IO.File.WriteAllLines(Environment.ExpandEnvironmentVariables(fullPath), mystrings, utf8WithoutBOM);
    

提交回复
热议问题