I have a script that works perfectly.
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto VERSION_7
However, when I try to print the results like so:
Echo Current OS:%vers% - 64 Bit
It prints the results with a really! long gap. Like so:
Current OS: Microsoft Windows 7 Enterprise - 64 Bit
Does anyone know why? or how I can remove the large gap?
Thanks a million!
Changed
FOR /F "usebackq delims=: tokens=2" %%i IN (osname.txt) DO set vers=%%i
To
FOR /F "usebackq delims= tokens=2" %%i IN (osname.txt) DO set vers=%%i
*Changed the : to a %space% after delims...
I know your script "works perfectly", but is not much efficient.
SYSTEMINFO
takes a lot of time and osname.txt
may be avoided.
Check:
FOR /F "TOKENS=1,* DELIMS==" %%u IN ('WMIC OS GET CAPTION /VALUE') DO IF /I "%%u"=="Caption" SET vers=%%v
OK, so this used to work, but all of a sudden stopped working ... Any ideas why?
@echo off
:Windows Version Check
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims= tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto VERSION_7
echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto VERSION_VISTA
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto VERSION_XP
:VERSION_7
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > checkOS.txt
Find /i "x86" < CheckOS.txt > StringCheck.txt
If %ERRORLEVEL% == 0 (
@Echo Current OS: %vers% - 32 Bit
) ELSE (
@Echo Current OS: %vers% - 64 Bit
)
I have a script that works perfectly.
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > osname.txt
FOR /F "usebackq delims=: tokens=2" %%i IN (osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto VERSION_7
However, when I try to print the results like so:
Echo Current OS:%vers% - 64 Bit
It prints the results with a really! long gap. Like so:
Current OS: Microsoft Windows 7 Enterprise - 64 Bit
Does anyone know why? or how I can remove the large gap?
Thanks a million!
Changed
FOR /F "usebackq delims=: tokens=2" %%i IN (osname.txt) DO set vers=%%i
To
FOR /F "usebackq delims= tokens=2" %%i IN (osname.txt) DO set vers=%%i
*Changed the : to a %space% after delims...
I know your script "works perfectly", but is not much efficient.
SYSTEMINFO
takes a lot of time and osname.txt
may be avoided.
Check:
FOR /F "TOKENS=1,* DELIMS==" %%u IN ('WMIC OS GET CAPTION /VALUE') DO IF /I "%%u"=="Caption" SET vers=%%v
OK, so this used to work, but all of a sudden stopped working ... Any ideas why?
@echo off
:Windows Version Check
if not exist %SystemRoot%\system32\systeminfo.exe goto warnthenexit
systeminfo | find "OS Name" > %TEMP%\osname.txt
FOR /F "usebackq delims= tokens=2" %%i IN (%TEMP%\osname.txt) DO set vers=%%i
echo %vers% | find "Windows 7" > nul
if %ERRORLEVEL% == 0 goto VERSION_7
echo %vers% | find "Windows Vista" > nul
if %ERRORLEVEL% == 0 goto VERSION_VISTA
ver | find "XP" > nul
if %ERRORLEVEL% == 0 goto VERSION_XP
:VERSION_7
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > checkOS.txt
Find /i "x86" < CheckOS.txt > StringCheck.txt
If %ERRORLEVEL% == 0 (
@Echo Current OS: %vers% - 32 Bit
) ELSE (
@Echo Current OS: %vers% - 64 Bit
)
0 commentaires:
Enregistrer un commentaire