35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
' MarineInvoice — Inicia servidor en segundo plano (sin ventana)
|
|
Option Explicit
|
|
Dim oShell, sDir, sPython, sLog
|
|
|
|
sDir = "C:\MarineInvoice"
|
|
sPython = "C:\Users\aerom\AppData\Local\Python\pythoncore-3.14-64\pythonw.exe"
|
|
sLog = sDir & "\logs\server.log"
|
|
|
|
Set oShell = CreateObject("WScript.Shell")
|
|
|
|
' Verificar si ya está corriendo en puerto 5000
|
|
Dim oExec, sOut
|
|
Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5000 | findstr LISTENING")
|
|
sOut = oExec.StdOut.ReadAll()
|
|
If Len(Trim(sOut)) > 0 Then
|
|
MsgBox "MarineInvoice ya está corriendo en el puerto 5000.", 64, "MarineInvoice"
|
|
WScript.Quit
|
|
End If
|
|
|
|
' Iniciar servidor oculto — redirige salida al log
|
|
oShell.Run "cmd /c cd /d """ & sDir & """ && """ & sPython & """ app.py >> """ & sLog & """ 2>&1", 0, False
|
|
|
|
WScript.Sleep 1500
|
|
|
|
' Confirmar que arrancó
|
|
Set oExec = oShell.Exec("cmd /c netstat -aon | findstr :5000 | findstr LISTENING")
|
|
sOut = oExec.StdOut.ReadAll()
|
|
If Len(Trim(sOut)) > 0 Then
|
|
MsgBox "MarineInvoice iniciado correctamente." & vbCrLf & vbCrLf & _
|
|
"URL: http://localhost:5000" & vbCrLf & _
|
|
"Tailscale: http://100.96.43.86:5000", 64, "MarineInvoice"
|
|
Else
|
|
MsgBox "El servidor tardó en iniciar. Revisa logs\server.log si hay errores.", 48, "MarineInvoice"
|
|
End If
|