فهرست منبع

perf(deploy): Administrator status

runhey 3 سال پیش
والد
کامیت
23b479325e
5فایلهای تغییر یافته به همراه29 افزوده شده و 38 حذف شده
  1. 0 19
      admin_test.py
  2. 22 16
      deploy/launcher/oas-gui.bat
  3. 3 0
      deploy/process.py
  4. 2 1
      module/gui/utils.py
  5. 2 2
      tasks/Script/config_error.py

+ 0 - 19
admin_test.py

@@ -1,19 +0,0 @@
-# This Python file uses the following encoding: utf-8
-# @author runhey
-# github https://github.com/runhey
-
-
-
-from module.gui.utils import check_admin
-
-
-
-if __name__ == "__main__":
-    # 检查是不是以管理员身份运行,脚本启动的其他进程会继承权限
-    # 但是貌似有问题的这个函数
-    check_admin()
-
-
-
-
-

+ 22 - 16
deploy/launcher/oas-gui.bat

@@ -1,7 +1,7 @@
 ::[Bat To Exe Converter]
 ::
 ::YAwzoRdxOk+EWAjk
-::fBw5plQjdCyDJGyX8VAjFJOkoIxy0O5J9Ik47fvw++WXnkESU+1xcYzUug==
+::fBw5plQjdCqDJGuB5E0jIQ9bXh2+M2qpS7wS+/z64+a7pkgNWO0mRIPaz7qNKOUB1knrcplj33lV+A==
 ::YAwzuBVtJxjWCl3EqQJgSA==
 ::ZR4luwNxJguZRRnk
 ::Yhs/ulQjdF+5
@@ -26,7 +26,7 @@
 ::ZQ0/vhVqMQ3MEVWAtB9wSA==
 ::Zg8zqx1/OA3MEVWAtB9wSA==
 ::dhA7pRFwIByZRRnk
-::Zh4grVQjdCyDJGyX8VAjFJOkoIxy0O5J9Ik47fvw++WXnkIcR6w6YIq7
+::Zh4grVQjdCqDJGuB5E0jIQ9bXh2+M2qpS7wS+/z64+a7rUwOGucnfe8=
 ::YB416Ek+ZG8=
 ::
 ::
@@ -34,34 +34,40 @@
 @rem
 @echo off
 
+color F0
+title oas Updater
+
+
+
+:: 璉��亦恣������
+>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
+
+:: 憒��餈𥪜��潔�蝑劐� 0嚗���齿鰵�臬𢆡�𡁏𧋦隞亥繮�𣇉恣������
+if %errorlevel% neq 0 (
+    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
+    echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
+    "%temp%\getadmin.vbs"
+    del "%temp%\getadmin.vbs"
+    exit /B
+)
+
+cd /d "%~dp0"
 set "_root=%~dp0"
 set "_root=%_root:~0,-1%"
 cd "%_root%"
 echo "%_root%
 
-color F0
-
 set "_pyBin=%_root%\toolkit"
 set "_GitBin=%_root%\toolkit\Git\mingw64\bin"
 set "_adbBin=%_root%\toolkit\Lib\site-packages\adbutils\binaries"
 set "PATH=%_root%\toolkit\alias;%_root%\toolkit\command;%_pyBin%;%_pyBin%\Scripts;%_GitBin%;%_adbBin%;%PATH%"
 
-title oas Updater
+
 python -m deploy.installer
 if %errorlevel% neq 0 (
     pause > nul
 ) else (
-    REM 璉��亦恣������
-    >nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
-    
-    REM 憒��銝𠹺��∪𦶢隞斤�餈𥪜��潔蛹0嚗��銵函內�瑟�蝞∠��䀹��?
-    if "%errorlevel%"=="0" (
-        REM 隞亦恣���頨思遢餈鞱� Python �𡁏𧋦
-        start /B pythonw gui.py
-    ) else (
-        REM 憒��瘝⊥�蝞∠��䀹��琜��嗘蝙�?PowerShell �𣂼�銝箇恣���頨思遢撟嗉�銵諹��?
-        PowerShell -Command "Start-Process -Verb RunAs pythonw  -ArgumentList gui.py"
-)
+    start /B pythonw gui.py
 )
 
 REM �喲𡡒�芾澈蝒堒藁

+ 3 - 0
deploy/process.py

@@ -64,5 +64,8 @@ class ProcessManager(DeployConfig):
         logger.hr(f'Kill existing Alas', 0)
         self.kill_by_name('oas.exe')
         self.kill_by_name('python.exe')
+        self.kill_by_name('pythonw.exe')
 
 
+if __name__ == '__main__':
+    ProcessManager().kill_by_name('pythonw')

+ 2 - 1
module/gui/utils.py

@@ -22,7 +22,8 @@ def is_admin():
     Check if the program is running as an admin.
     """
     try:
-        return ctypes.windll.shell32.IsUserAnAdmin()
+        result = ctypes.windll.shell32.IsUserAnAdmin()
+        return result == 1
     except:
         return False
 

+ 2 - 2
tasks/Script/config_error.py

@@ -7,9 +7,9 @@ from module.logger import logger
 
 
 class Error(BaseModel):
-    handle_error: bool = Field(default=False,
+    handle_error: bool = Field(default=True,
                                description='handle_error_help')
-    save_error: bool = Field(default=False,
+    save_error: bool = Field(default=True,
                              description='')
     screenshot_length: int = Field(default=1,
                                    description='')