update osstartup
This commit is contained in:
parent
64ac027005
commit
86c7de1d9a
2 changed files with 19 additions and 6 deletions
|
|
@ -10,14 +10,14 @@ import 'package:dart_framework/charset.dart';
|
|||
|
||||
void main() async {
|
||||
Application('dartframework', 'com.toki-labs.dartframework', () async {
|
||||
// print(await OSStartup.unregistStartup(appIdendifier));
|
||||
print(await OSStartup.unregistStartup(appIdendifier));
|
||||
|
||||
// print(await OSStartup.isRegistedStartup(appIdendifier));
|
||||
|
||||
print(await OSStartup.registStartup(
|
||||
Platform.resolvedExecutable, appIdendifier,
|
||||
logStandardFilePath: '$dataPath\\startup_log.txt',
|
||||
logErrorFilePath: '$dataPath\\startup_err.txt'));
|
||||
// print(await OSStartup.registStartup(
|
||||
// Platform.resolvedExecutable, appIdendifier,
|
||||
// logStandardFilePath: '$dataPath\\startup_log.txt',
|
||||
// logErrorFilePath: '$dataPath\\startup_err.txt'));
|
||||
|
||||
// var md5 = generateMd5('test');
|
||||
// print('$md5 / ${md5.length}');
|
||||
|
|
|
|||
|
|
@ -316,6 +316,11 @@ Register-ScheduledTask -TaskName \$TaskName -Action \$Action -Trigger \$Trigger
|
|||
Exit
|
||||
''';
|
||||
|
||||
String getScriptPath(String label) {
|
||||
var debugPath = isDebug ? '.debug' : '';
|
||||
return '${dataPath.replaceAll('/', '\\')}$debugPath\\$label.ps1';
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> isRegistedStartup(String label) async {
|
||||
var shell = 'Get-ScheduledTask | Where-Object {\$_.TaskName -eq "$label"}';
|
||||
|
|
@ -343,7 +348,7 @@ Exit
|
|||
{List<String>? arguments,
|
||||
String? logStandardFilePath,
|
||||
String? logErrorFilePath}) async {
|
||||
var scriptPath = '${dataPath.replaceAll('/', '\\')}\\$label.ps1';
|
||||
var scriptPath = getScriptPath(label);
|
||||
var startupScript = startupScriptTemplate.replaceAll(
|
||||
'{EXECUTABLE_PATH}', executableFilePath.replaceAll('/', '\\'));
|
||||
var args = '';
|
||||
|
|
@ -389,6 +394,8 @@ Exit
|
|||
print(process.stderr.toString());
|
||||
print(process.exitCode);
|
||||
|
||||
tempFile.deleteSync();
|
||||
|
||||
return dataFutrue(process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
|
@ -406,6 +413,12 @@ Exit
|
|||
print(process.stdout.toString());
|
||||
print(process.stderr.toString());
|
||||
print(process.exitCode);
|
||||
|
||||
var scriptFile = File(getScriptPath(label));
|
||||
if (scriptFile.existsSync()) {
|
||||
scriptFile.deleteSync();
|
||||
}
|
||||
|
||||
return dataFutrue(process.exitCode == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue