This commit is contained in:
xkeyC 2023-11-08 20:48:48 +08:00
parent 024310cd5b
commit e0d0d16ed0
4 changed files with 12 additions and 30 deletions

View File

@ -16,8 +16,8 @@ import 'package:window_manager/window_manager.dart';
import '../base/ui.dart';
class AppConf {
static const String appVersion = "2.9.10 Beta";
static const int appVersionCode = 25;
static const String appVersion = "2.9.12 Beta";
static const int appVersionCode = 27;
static const String appVersionDate = "2023-11-03";
static const String gitlabHomeUrl =
@ -46,9 +46,6 @@ class AppConf {
static const isMSE =
String.fromEnvironment("MSE", defaultValue: "false") == "true";
static final launchHelperPath =
"${AppConf.applicationSupportDir}\\launch_helper.vbs";
static init(List<String> args) async {
dPrint("launch args == $args");
WidgetsFlutterBinding.ensureInitialized();

View File

@ -1,6 +1,5 @@
import 'dart:io';
import 'package:starcitizen_doctor/common/conf.dart';
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
class SystemHelper {
@ -198,24 +197,4 @@ 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
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("""${Platform.resolvedExecutable}""")
Set objShell = Nothing
''';
final vbsFile = File(AppConf.launchHelperPath);
if (await vbsFile.exists()) {
await vbsFile.delete();
}
await vbsFile.create();
await vbsFile.writeAsString(script);
}
}

View File

@ -3,6 +3,7 @@
import 'dart:io';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';
import 'package:starcitizen_doctor/common/helper/log_helper.dart';
import 'api/api.dart';
@ -70,9 +71,14 @@ class AppGlobalUIModel extends BaseUIModel {
}
_runAsAdmin() async {
await SystemHelper.initVBS();
await Process.run(
SystemHelper.powershellPath, [AppConf.launchHelperPath]);
final box = await Hive.openBox("app_conf");
await box.close();
await Process.run(SystemHelper.powershellPath, [
"""
Start-Process powershell -Verb RunAs -ArgumentList "Start-Process '${Platform.resolvedExecutable}' -Verb RunAs"
"""
]);
await Future.delayed(const Duration(seconds: 2));
exit(0);
}
}

View File

@ -125,7 +125,7 @@ msix_config:
publisher_display_name: xkeyC Studio
identity_name: 56575xkeyC.MSE
publisher: CN=B54C897B-C263-4680-B6AB-4913C603DF87
msix_version: 2.9.10.0
msix_version: 2.9.12.0
logo_path: ./assets/app_logo.png
capabilities: internetClient
languages: zh-cn