'use strict
' Arranque silencioso del ecosistema de bandejas (sin flash).
' No depende de argumentos: Task Scheduler / Run key a prueba de fallos.
Dim sh, fso, node, js, cmd, logFile
Set sh = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")
logFile = "C:\xampp\htdocs\JobsWorld\data\ecosystem-boot.log"

Sub Log(msg)
  On Error Resume Next
  Dim ts
  Set ts = fso.OpenTextFile(logFile, 8, True)
  ts.WriteLine Now & " boot.vbs " & msg
  ts.Close
End Sub

node = "C:\Program Files\nodejs\node.exe"
If Not fso.FileExists(node) Then node = "C:\Program Files (x86)\nodejs\node.exe"
js = "C:\xampp\htdocs\JobsWorld\scripts\tray\ecosystem_boot.js"

If Not fso.FileExists(node) Then
  Log "FAIL no node.exe"
  WScript.Quit 1
End If
If Not fso.FileExists(js) Then
  Log "FAIL no ecosystem_boot.js"
  WScript.Quit 1
End If

Log "START " & node & " " & js
' window style 0 = oculto; False = no esperar (el boot.js tarda ~20s)
cmd = """" & node & """ """ & js & """"
sh.Run cmd, 0, False
WScript.Quit 0
