Option Explicit Dim fso, shell, baseDir, launcher, pyw, py, cmd Set fso = CreateObject("Scripting.FileSystemObject") Set shell = CreateObject("WScript.Shell") baseDir = fso.GetParentFolderName(WScript.ScriptFullName) launcher = baseDir & "\ERPAgentDashboard.pyw" pyw = baseDir & "\.venv\Scripts\pythonw.exe" py = baseDir & "\.venv\Scripts\python.exe" If Not fso.FileExists(launcher) Then MsgBox "ERPAgentDashboard.pyw was not found in " & baseDir, 16, "ERP Local Agent" WScript.Quit End If If fso.FileExists(pyw) Then cmd = Chr(34) & pyw & Chr(34) & " " & Chr(34) & launcher & Chr(34) ElseIf fso.FileExists(py) Then cmd = Chr(34) & py & Chr(34) & " " & Chr(34) & launcher & Chr(34) Else MsgBox "ERP Local Agent Python environment was not found.", 16, "ERP Local Agent" WScript.Quit End If shell.Run cmd, 0, False