----------------------------------------------------------------------------------------------------------
脚本正文
----------------------------------------------------------------------------------------------------------
@echo off
path==%systemroot%\system32;%systemroot%;%systemdrive%\;
set find=%systemroot%\system32\find.exe
title 确定操作系统的运行环境
color 1a
cls
:Find_Out_OS
regedit /e filename keyname
:/*********
rem 或者 reg export keyname filename
rem 导出的注册表文件大小大约是上面的1/9
:**********/
type "filename"|"%find%" /i "strings1" >nul
if errorlevel==1 (
type "filename"|"%find%" /i "strings2" >NUL
if errorlevel==1 (
SET windows_OS=FALSE
echo 未发现有效的操作系统!
goto NO_FIND_OS
)
SET windows_OS=FALSE
echo 您的系统当前运行在DOS下!
goto :NO_windows_OS
)
SET windows_OS=TRUE
echo 您的系统当前运行在windows下!
goto :NO_DOS_OS
:NO_DOS_OS
if windows_OS=TRUE command /options
............(执行命令部分)
NO_windows_OS
if windows_OS=FlASE command /options
...............(执行命令部分)
:NO_FIND_OS
if windows_OS=FlASE command /options
............(执行命令部分)