'windows batch keep returning a sytax error: cant find the hitch
just want my batch to rotate screen, open a program, and rotate back when closed:
REM starts by rotating the screen using a program called display64
START C:\Users\Admin\Downloads\display\display64.exe /rotate:90
REM then waits a time so the sceen has time to reorient on the monitor.
SLEEP 10
REM then launches the game
cd "C:\Program Files\Pinball FX2"
"Pinball FX2.exe"
REM start a loop where the batch seees if the game is running and leaves the screen alone
:LOOP
ECHO tasklist loop starting
tasklist | FIND "Pinball FX2.exe" >nul
IF %errorlevel% 1 (
ECHO program not running anymore ---> rotate back!
GOTO CONTINUE
)
ECHO tasklist loop returned to start
ELSE (
ECHO pinfx2 still runnning, restarting loop
TIMEOUT /T 5 /Nobreak
GOTO LOOP
)
ECHO tasklist loop returned showing its closed...stopping loop
REM if the program closes, batch rotates the screen back
:CONTINUE
START C:\Users\Admin\Downloads\display\display64.exe /rotate:0
Exit 0
but I run the batch in a cmd window, with the verbose flag...and this (after forcekilling the game. alt+f4):
C:\Users\Admin\Desktop\launching shorts>"pinfx2 and rotate 90.cmd" -v
C:\Users\Admin\Desktop\launching shorts>REM starts by rotating the screen using a program called display64
C:\Users\Admin\Desktop\launching shorts>START C:\Users\Admin\Downloads\display\display64.exe /rotate:90
C:\Users\Admin\Desktop\launching shorts>REM then waits a time so the sceen has time to reorient on the monitor.
C:\Users\Admin\Desktop\launching shorts>SLEEP 10
C:\Users\Admin\Desktop\launching shorts>REM then launches the game
C:\Users\Admin\Desktop\launching shorts>cd "C:\Program Files\Pinball FX2"
C:\Program Files\Pinball FX2>"Pinball FX2.exe"
C:\Program Files\Pinball FX2>REM start a loop where the batch seees if the game is running and leaves the screen alone.
C:\Program Files\Pinball FX2>tasklist | FIND "Pinball FX2.exe" 1>nul
The syntax of the command is incorrect.
C:\Program Files\Pinball FX2>IF ERRORLEVEL 1(
C:\Program Files\Pinball FX2>
sorry if this seems trivial....I've never had to post before and learned alot of this in the 90s.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
