使用新的方法申请UAC

This commit is contained in:
2023-11-06 22:23:06 +08:00
parent 1f68ad8ded
commit 403840ef12
7 changed files with 65 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import 'dart:io';
import 'package:starcitizen_doctor/common/conf.dart';
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
class SystemHelper {
@ -179,4 +180,24 @@ foreach ($adapter in $adapterMemory) {
} catch (_) {}
return totalSize;
}
static initVBS() async {
final script = '''
If Not WScript.Arguments.Named.Exists("elevate") Then
CreateObject("Shell.Application").ShellExecute WScript.FullName _
, """" & WScript.ScriptFullName & """ /elevate", "", "runas", 1
WScript.Quit
End If
Set WshShell = WScript.CreateObject("WScript.Shell")
exeName = """${Platform.resolvedExecutable}"""
statusCode = WshShell.Run(exeName, 1, true)
''';
final vbsFile = File(AppConf.launchHelperPath);
if (await vbsFile.exists()) {
await vbsFile.delete();
}
await vbsFile.create();
await vbsFile.writeAsString(script);
}
}