【随笔】使用bat脚本判断操作系统

 

说明:

该脚本首先判断当前操作系统,然后判断该系统是32位还是64位系统,最后根据不同的系统执行不同命令。

@echo off

ver | find "6.1." > NUL &&  goto win7 
ver | find "10.0." > NUL && goto win10 goto end :win7 if exist "c:\agentinstalled.txt" goto end if not exist "c:\agentinstalled.txt" goto first :win10 if exist "c:\agentinstalled.txt" goto end if not exist "c:\agentinstalled.txt" goto second :first if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( echo "first x64" > "c:\agentinstalled.txt" )^ else if "%PROCESSOR_ARCHITECTURE%"=="x86" ( echo " first x86" > "c:\agentinstalled.txt" ) goto end :second if "%PROCESSOR_ARCHITECTURE%"=="AMD64" ( echo "second x64" > "c:\pagentinstalled.txt" )^ else if "%PROCESSOR_ARCHITECTURE%"=="x86" ( echo "second x86 > "c:\agentinstalled.txt" ) goto end :end exit

 

posted @ 2021-06-24 16:40  吧唧君  阅读(483)  评论(0编辑  收藏  举报