diff --git a/lib/utils/os_startup.dart b/lib/utils/os_startup.dart index 3a86956..6766276 100644 --- a/lib/utils/os_startup.dart +++ b/lib/utils/os_startup.dart @@ -251,8 +251,18 @@ class _StartupWindows extends _Startup { Future isRegistedStartup(String label) async { var c = Completer(); //For Windows 8, 10 + var exist = false; var userPath = Platform.environment['UserProfile']; - c.complete(File('$userPath$windowsStartupPath$label').existsSync()); + var startupDir = Directory('$userPath$windowsStartupPath'); + var files = await startupDir.listSync(); + for (var fileEntry in files) { + var fileName = path.basename(fileEntry.path); + if (fileName == label) { + exist = true; + break; + } + } + c.complete(exist); return c.future; } @@ -267,7 +277,8 @@ class _StartupWindows extends _Startup { ProcessResult? result; //For Windows 8, 10 var fileName = path.basename(file.path); - var symbolicPath = '%userprofile%$windowsStartupPath$fileName'; + var extension = path.extension(fileName); + var symbolicPath = '%userprofile%$windowsStartupPath$label$extension'; result = await ProcessExecutor.run( StringBuffer('mklink "$symbolicPath" "$executableFilePath"')); c.complete(result.exitCode == 0); @@ -280,10 +291,15 @@ class _StartupWindows extends _Startup { var success = false; //For Windows 8, 10 var userPath = Platform.environment['UserProfile']; - var file = File('$userPath$windowsStartupPath$label'); - if (file.existsSync()) { - await file.delete(); - success = true; + var startupDir = Directory('$userPath$windowsStartupPath'); + var files = await startupDir.listSync(); + for (var fileEntry in files) { + var fileName = path.basename(fileEntry.path); + if (fileName == label) { + await File(fileEntry.path).delete(); + success = true; + break; + } } c.complete(success); return c.future;