mirror of
https://github.com/FAUSheppy/homelab_gamevault
synced 2026-01-21 18:37:39 +01:00
Compare commits
3 Commits
3545ecbaa8
...
1c48b033d3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c48b033d3 | ||
|
|
68f14c0831 | ||
|
|
de0627bbcd |
@@ -25,6 +25,7 @@ buttons = []
|
||||
details_elements = []
|
||||
|
||||
non_disabled_entry_color = None
|
||||
all_metadata = None
|
||||
|
||||
db = None # app data-backend (i.e. LocalFS or FTP)
|
||||
|
||||
@@ -170,6 +171,8 @@ def switch_to_game_details(software):
|
||||
def load_main():
|
||||
'''Load the main page overview'''
|
||||
|
||||
global all_metadata
|
||||
|
||||
app.title("Lan Vault: Overview")
|
||||
|
||||
# navbar should not expand when window is resized
|
||||
@@ -183,7 +186,10 @@ def load_main():
|
||||
|
||||
# create tiles from meta files #
|
||||
cache_dir_size = 0
|
||||
for software in db.find_all_metadata():
|
||||
if not all_metadata:
|
||||
all_metadata = db.find_all_metadata()
|
||||
|
||||
for software in all_metadata:
|
||||
|
||||
print("Software:", software)
|
||||
create_main_window_tile(software, scrollable_frame)
|
||||
|
||||
@@ -156,7 +156,7 @@ def create_details_page(app, software, backswitch_function):
|
||||
|
||||
# install button #
|
||||
print(software.run_exe)
|
||||
print(os.path.join(software.backend.install_dir, software.run_exe))
|
||||
print(os.path.join(software.backend.install_dir, software.run_exe or ""))
|
||||
if not software.run_exe or not (os.path.isfile(software.run_exe)
|
||||
or os.path.isfile(os.path.join(software.backend.install_dir, software.title, software.run_exe))):
|
||||
run_button.configure(state=tkinter.DISABLED)
|
||||
|
||||
@@ -71,7 +71,7 @@ def run_exe(path, synchronous=False):
|
||||
subprocess.Popen(path, cwd=os.path.dirname(path))
|
||||
except OSError as e:
|
||||
if "WinError 740" in str(e):
|
||||
p = subprocess.Popen(["python", "adminrun.py", path],
|
||||
p = subprocess.Popen(["powershell", "-ExecutionPolicy", "Bypass", "-File", "windows_run_as_admin.ps1", path],
|
||||
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||
print(p.communicate())
|
||||
else:
|
||||
|
||||
27
windows_run_as_admin.ps1
Normal file
27
windows_run_as_admin.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
param (
|
||||
[string]$Path
|
||||
)
|
||||
|
||||
# Check if running as administrator
|
||||
$CurrentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$Principal = New-Object System.Security.Principal.WindowsPrincipal($CurrentUser)
|
||||
$IsAdmin = $Principal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
|
||||
|
||||
if (-not $IsAdmin) {
|
||||
# Relaunch the script with elevated privileges
|
||||
Start-Process powershell -ArgumentList "-File `"$PSCommandPath`" `"$Path`"" -Verb RunAs
|
||||
exit
|
||||
}
|
||||
|
||||
# Run the process and capture output
|
||||
try {
|
||||
$Process = Start-Process -FilePath $Path -NoNewWindow -PassThru -RedirectStandardOutput output.txt -RedirectStandardError error.txt
|
||||
$Process.WaitForExit()
|
||||
|
||||
# Read and display output
|
||||
Get-Content output.txt
|
||||
Get-Content error.txt | ForEach-Object { Write-Host $_ -ForegroundColor Red }
|
||||
|
||||
} catch {
|
||||
Write-Host "Error running the process: $_" -ForegroundColor Red
|
||||
}
|
||||
Reference in New Issue
Block a user