Detect if a batch file is executed within Windows
1 January 2000 by Snakefoot | Comment » | Trackback OffIt is possible to detect within a batch file if it was executed in a Windows environment. This is done by checking for the environment variable WINDIR, which is exists in the Windows environment. This can be used ex. if having an application that cannot execute properly in the Windows environment:
Note one can also check whether one is executing in Windows NT or Windows 9x. This is done by checking for the enviroment variable SYSTEMROOT, which is created by the Windows NT enviroment:
More Info MS KB Q85469@EHCO OFF
IF NOT "%WINDIR%"=="" GOTO EXIT
DOSPROG.EXE
:EXIT
Note one can also check whether one is executing in Windows NT or Windows 9x. This is done by checking for the enviroment variable SYSTEMROOT, which is created by the Windows NT enviroment:
More Info MS KB Q190899@EHCO OFF
IF NOT "%SYSTEMROOT%"=="" GOTO WINNT
IF NOT "%WINDIR%"=="" GOTO WIN9X
GOTO DOS
Updated: 23 September 2007