@echo off
REM Set-MachineNumber.bat - Wrapper for Set-MachineNumber.ps1
REM
REM Looks for the .ps1 in three places, in order:
REM   1. %~dp0Set-MachineNumber.ps1
REM      - .bat and .ps1 side-by-side (normal desktop-copied case, repo layout)
REM   2. C:\Users\SupportUser\Desktop\Set-MachineNumber.ps1
REM      - dispatcher-copied location, if this .bat lives somewhere else
REM   3. C:\Enrollment\shopfloor-setup\Standard\Set-MachineNumber.ps1
REM      - canonical enrollment staging copy
REM
REM Goto-based dispatch - no nested if blocks, no literal parens in echo lines.
REM CMD parses "if (...)" blocks by counting parens and will silently eat any
REM "(" or ")" inside an echo, so keeping the flow flat avoids that class of
REM syntax bomb entirely.

setlocal
set "PS1=%~dp0Set-MachineNumber.ps1"
if exist "%PS1%" goto :run

set "PS1=C:\Users\SupportUser\Desktop\Set-MachineNumber.ps1"
if exist "%PS1%" goto :run

set "PS1=C:\Enrollment\shopfloor-setup\Standard\Set-MachineNumber.ps1"
if exist "%PS1%" goto :run

echo ERROR: Set-MachineNumber.ps1 not found in any of:
echo   %~dp0Set-MachineNumber.ps1
echo   C:\Users\SupportUser\Desktop\Set-MachineNumber.ps1
echo   C:\Enrollment\shopfloor-setup\Standard\Set-MachineNumber.ps1
echo.
pause
exit /b 1

:run
echo Launching: %PS1%
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS1%"
exit /b %errorlevel%
