From 1df89bcf1ce66671969993b99e6327664f5a9143 Mon Sep 17 00:00:00 2001 From: Rishi Patel Date: Fri, 17 Jul 2026 14:24:46 -0400 Subject: [PATCH] Fix Windows no-terminal launcher discovery --- launchers/windows/Start Local RLM Cowork.vbs | 75 +++++++++++++++++--- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/launchers/windows/Start Local RLM Cowork.vbs b/launchers/windows/Start Local RLM Cowork.vbs index 47f7129a..c2986b8d 100644 --- a/launchers/windows/Start Local RLM Cowork.vbs +++ b/launchers/windows/Start Local RLM Cowork.vbs @@ -1,24 +1,77 @@ Option Explicit -Dim shell, fso, scriptDir, repoDir, launcher, command, candidate, pythonw +Dim shell, fso, scriptDir, repoDir, launcher, command, pythonCommand Set shell = CreateObject("WScript.Shell") Set fso = CreateObject("Scripting.FileSystemObject") + scriptDir = fso.GetParentFolderName(WScript.ScriptFullName) repoDir = fso.GetParentFolderName(fso.GetParentFolderName(scriptDir)) launcher = fso.BuildPath(repoDir, "launchers\launcher.pyw") -pythonw = "" -For Each candidate In Array("pyw.exe -3.11", "pyw.exe -3", "pythonw.exe") - If shell.Run("cmd /c """ & Split(candidate, " ")(0) & """ --version", 0, True) = 0 Then - pythonw = candidate - Exit For - End If -Next +If Not fso.FileExists(launcher) Then + MsgBox "The graphical launcher could not be found:" & vbCrLf & launcher & vbCrLf & vbCrLf & _ + "Extract the complete Windows bundle before starting it. Do not run the VBS file from inside the ZIP archive.", _ + 16, "Local RLM Cowork" + WScript.Quit 1 +End If -If pythonw = "" Then - MsgBox "Python 3.11 or newer was not found. Install Python from python.org and enable the Python launcher, then double-click this file again.", 16, "Local RLM Cowork" +pythonCommand = FindPythonCommand(shell, fso) +If pythonCommand = "" Then + MsgBox "Python 3.11 or newer was not found." & vbCrLf & vbCrLf & _ + "Install 64-bit Python from python.org. On the first installer screen, enable 'Add python.exe to PATH' and install the Python launcher." & vbCrLf & vbCrLf & _ + "Then double-click this launcher again.", 16, "Local RLM Cowork" WScript.Quit 1 End If -command = pythonw & " """ & launcher & """" +command = pythonCommand & " """ & launcher & """" shell.Run command, 0, False + +Function FindPythonCommand(shellObject, fileSystem) + Dim localAppData, programFiles, programFilesX86, candidates, candidate + + localAppData = shellObject.ExpandEnvironmentStrings("%LocalAppData%") + programFiles = shellObject.ExpandEnvironmentStrings("%ProgramFiles%") + programFilesX86 = shellObject.ExpandEnvironmentStrings("%ProgramFiles(x86)%") + + candidates = Array( _ + "py.exe -3.13", _ + "py.exe -3.12", _ + "py.exe -3.11", _ + Quote(fileSystem.BuildPath(localAppData, "Programs\Python\Python313\pythonw.exe")), _ + Quote(fileSystem.BuildPath(localAppData, "Programs\Python\Python312\pythonw.exe")), _ + Quote(fileSystem.BuildPath(localAppData, "Programs\Python\Python311\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFiles, "Python313\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFiles, "Python312\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFiles, "Python311\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFilesX86, "Python313\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFilesX86, "Python312\pythonw.exe")), _ + Quote(fileSystem.BuildPath(programFilesX86, "Python311\pythonw.exe")), _ + "pythonw.exe" _ + ) + + For Each candidate In candidates + If CommandWorks(shellObject, CStr(candidate)) Then + FindPythonCommand = CStr(candidate) + Exit Function + End If + Next + + FindPythonCommand = "" +End Function + +Function CommandWorks(shellObject, candidateCommand) + Dim exitCode + On Error Resume Next + exitCode = shellObject.Run(candidateCommand & " --version", 0, True) + If Err.Number <> 0 Then + Err.Clear + CommandWorks = False + Else + CommandWorks = (exitCode = 0) + End If + On Error GoTo 0 +End Function + +Function Quote(value) + Quote = """" & value & """" +End Function