' Registra el agente en el inicio de Windows (carpeta Startup del usuario actual).
' Ejecutar una vez con doble clic. No requiere rutas fijas: usa la carpeta donde está print-agent.

Option Explicit

Dim fso, shell, agentRoot, startupVbs, startupFolder, shortcutPath, shortcut

Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")

agentRoot = fso.GetParentFolderName(WScript.ScriptFullName)
startupVbs = agentRoot & "\EgurrolaPrintAgent-startup.vbs"
startupFolder = shell.SpecialFolders("Startup")
shortcutPath = startupFolder & "\Egurrola Print Agent.lnk"

If Not fso.FileExists(startupVbs) Then
    MsgBox "No se encontró EgurrolaPrintAgent-startup.vbs en:" & vbCrLf & agentRoot, vbCritical, "Egurrola Print Agent"
    WScript.Quit 1
End If

Set shortcut = shell.CreateShortcut(shortcutPath)
shortcut.TargetPath = startupVbs
shortcut.WorkingDirectory = agentRoot
shortcut.Description = "Agente de impresión térmica Clinica Egurrola"
shortcut.WindowStyle = 7
shortcut.Save

MsgBox "Inicio automático configurado." & vbCrLf & vbCrLf & _
       "Acceso directo:" & vbCrLf & shortcutPath & vbCrLf & vbCrLf & _
       "Carpeta del agente:" & vbCrLf & agentRoot & vbCrLf & vbCrLf & _
       "El agente se ejecutará al iniciar sesión en Windows (sin ventana visible)." & vbCrLf & _
       "Para quitarlo, ejecute desinstalar-inicio-windows.vbs", vbInformation, "Egurrola Print Agent"
