问题解决工具: 删除开机启动

This commit is contained in:
ZouJin 2023-09-12 12:51:23 +08:00
parent 539db25af7
commit cfbc7c64bd
3 changed files with 25 additions and 4 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
@ -13,5 +14,24 @@ namespace VPet.Solution
/// </summary>
public partial class App : Application
{
public static bool IsDone { get; set; } = false;
protected override void OnStartup(StartupEventArgs e)
{
if (e.Args != null && e.Args.Count() > 0)
{
IsDone = true;
switch (e.Args[0].ToLower())
{
case "removestarup":
var path = Environment.GetFolderPath(Environment.SpecialFolder.Startup) + @"\VPET_Simulator.lnk";
if(File.Exists(path))
{
File.Delete(path);
}
return;
}
}
IsDone = false;
}
}
}

View File

@ -22,6 +22,11 @@ namespace VPet.Solution
{
public MainWindow()
{
if (App.IsDone)
{
Close();
return;
}
InitializeComponent();
}
}

View File

@ -116,10 +116,6 @@
<Project>{dcad838a-1a02-4bdf-962c-fd47c6006d28}</Project>
<Name>VPet-Simulator.Windows.Interface</Name>
</ProjectReference>
<ProjectReference Include="..\VPet-Simulator.Windows\VPet-Simulator.Windows.csproj">
<Project>{b5c2dd17-735f-4f9f-82e4-b8692aec03f1}</Project>
<Name>VPet-Simulator.Windows</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>