Set WshShell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

' Get project directory from current script location
Dim scriptPath, projectDir
scriptPath = WScript.ScriptFullName
projectDir = fso.GetParentFolderName(scriptPath)

' Detect XAMPP directory
Dim xamppDir
If fso.FolderExists(projectDir & "\..\..") And fso.FileExists(projectDir & "\..\..\apache_start.bat") Then
    xamppDir = fso.GetAbsolutePathName(projectDir & "\..\..")
ElseIf fso.FolderExists("D:\xampp") Then
    xamppDir = "D:\xampp"
ElseIf fso.FolderExists("C:\xampp") Then
    xamppDir = "C:\xampp"
ElseIf fso.FolderExists("F:\xampp") Then
    xamppDir = "F:\xampp"
Else
    xamppDir = ""
End If

' Start Apache and MySQL silently if XAMPP found
If xamppDir <> "" Then
    WshShell.Run "cmd /c cd /d """ & xamppDir & """ && apache_start.bat", 0, False
    WshShell.Run "cmd /c cd /d """ & xamppDir & """ && mysql_start.bat", 0, False
End If

WScript.Sleep 3000

' Start Laravel development server
WshShell.Run "cmd /c cd /d """ & projectDir & """ && php artisan serve --port=8000", 0, False

' Start Laravel Scheduler
WshShell.Run "cmd /c cd /d """ & projectDir & """ && php artisan schedule:work", 0, False

WScript.Sleep 3000

' Open Chrome in desktop app mode with silent kiosk printing to default printer
WshShell.Run """C:\Program Files\Google\Chrome\Application\chrome.exe"" --kiosk-printing --use-system-default-printer --user-data-dir=""" & projectDir & "\storage\chrome_pos_profile"" --app=http://127.0.0.1:8000 --window-size=1400,900", 1, False
