windows startup change filename by label
This commit is contained in:
parent
12b43bf574
commit
88a2aa70aa
1 changed files with 22 additions and 6 deletions
|
|
@ -251,8 +251,18 @@ class _StartupWindows extends _Startup {
|
|||
Future<bool> isRegistedStartup(String label) async {
|
||||
var c = Completer<bool>();
|
||||
//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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue