fix: installer buttons (Durchsuchen/Freigabe holen), Worker-Start via os.startfile, Shortcut via PowerShell

This commit is contained in:
Hitonabi
2026-07-26 22:15:50 +02:00
parent de500f9890
commit 06c1718a52
2 changed files with 32 additions and 13 deletions
+32 -13
View File
@@ -200,18 +200,26 @@ if (-not $Force) {{ [System.Windows.Forms.MessageBox]::Show("Rippy-Worker entfer
bat_path = os.path.join(install_dir, "start-gui.bat")
subprocess.run(f'schtasks /create /tn "RippyWorker" /tr "\\"{bat_path}\\"" /sc ONLOGON /rl HIGHEST /f', shell=True, capture_output=True)
# Desktop Shortcut
# Desktop Shortcut — ueber PowerShell/COM, weil win32com im
# PyInstaller-Bundle nicht enthalten ist.
if chk_desktop.value:
try:
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
public_desktop = os.environ.get("PUBLIC", "") + "\\Desktop"
desktop = public_desktop if "Program Files" in install_dir and os.path.exists(public_desktop) else shell.SpecialFolders("Desktop")
shortcut = shell.CreateShortCut(os.path.join(desktop, "Rippy Worker.lnk"))
shortcut.Targetpath = os.path.join(install_dir, "start-gui.bat")
shortcut.WorkingDirectory = install_dir
shortcut.IconLocation = os.path.join(install_dir, "rippy.ico")
shortcut.save()
public_desktop = os.path.join(os.environ.get("PUBLIC", r"C:\Users\Public"), "Desktop")
user_desktop = os.path.join(os.path.expanduser("~"), "Desktop")
desktop = public_desktop if "Program Files" in install_dir and os.path.isdir(public_desktop) else user_desktop
lnk_path = os.path.join(desktop, "Rippy Worker.lnk")
bat_target = os.path.join(install_dir, "start-gui.bat")
ico_path = os.path.join(install_dir, "rippy.ico")
ps_cmd = (
f'$ws = New-Object -ComObject WScript.Shell; '
f'$sc = $ws.CreateShortcut(\"{lnk_path}\"); '
f'$sc.TargetPath = \"{bat_target}\"; '
f'$sc.WorkingDirectory = \"{install_dir}\"; '
f'$sc.IconLocation = \"{ico_path}\"; '
f'$sc.WindowStyle = 7; '
f'$sc.Save()'
)
subprocess.run(["powershell", "-NoProfile", "-Command", ps_cmd], capture_output=True)
log("Desktop-Verknüpfung erstellt.")
except Exception as e:
log(f"Warnung: Shortcut konnte nicht erstellt werden: {e}")
@@ -224,12 +232,23 @@ if (-not $Force) {{ [System.Windows.Forms.MessageBox]::Show("Rippy-Worker entfer
def start_worker(e):
install_dir = txt_pfad.value.strip()
subprocess.Popen(os.path.join(install_dir, "start-gui.bat"), creationflags=subprocess.CREATE_NO_WINDOW)
bat_path = os.path.join(install_dir, "start-gui.bat")
# os.startfile startet die .bat ueber die Shell-Verknuepfung —
# CREATE_NO_WINDOW wuerde sie stumm schlucken.
os.startfile(bat_path)
page.window_close()
btn_install = ft.ElevatedButton("Installieren", on_click=do_install, bgcolor=c_accent, color=ft.colors.WHITE, width=200, height=40)
btn_start = ft.ElevatedButton("Worker starten", on_click=start_worker, bgcolor=c_success, color=ft.colors.WHITE, width=200, height=40, visible=False)
def get_dir(e: ft.FilePickerResultEvent):
if e.path:
txt_pfad.value = e.path
page.update()
dir_picker = ft.FilePicker(on_result=get_dir)
page.overlay.append(dir_picker)
page.add(
ft.Row([
ft.Icon(ft.icons.DISC_FULL, size=40, color=c_accent),
@@ -239,8 +258,8 @@ if (-not $Force) {{ [System.Windows.Forms.MessageBox]::Show("Rippy-Worker entfer
ft.Divider(color="#334155"),
ft.Row([txt_host], alignment=ft.MainAxisAlignment.START),
ft.Row([txt_name, txt_slots], alignment=ft.MainAxisAlignment.START),
ft.Row([txt_pfad, ft.ElevatedButton("Rippy holen", on_click=check_map, bgcolor=c_panel, color=c_text)], alignment=ft.MainAxisAlignment.START),
ft.Row([txt_map, ft.ElevatedButton("Freigabe testen", on_click=check_map, bgcolor=c_panel, color=c_text)], alignment=ft.MainAxisAlignment.START),
ft.Row([txt_pfad, ft.ElevatedButton("Durchsuchen ...", on_click=lambda _: dir_picker.get_directory_path("Installationsordner wählen"), bgcolor=c_panel, color=c_text)], alignment=ft.MainAxisAlignment.START),
ft.Row([txt_map, ft.ElevatedButton("Freigabe holen", on_click=check_map, bgcolor=c_panel, color=c_text)], alignment=ft.MainAxisAlignment.START),
chk_auto,
chk_desktop,
ft.Container(content=log_view, bgcolor="#020617", padding=10, border_radius=5, border=ft.border.all(1, "#334155")),