Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal
- set prefix=G:\Directory
- :: See "wmic /help" for more information about wmic.
- :: From the output of "wmic os get name, version /format:list" set "name=os name" and "version=os version" (but stopping if a pipe (a "|" symbol) is encountered)
- for /f "usebackq tokens=1,2 delims==|" %%I in (`wmic os get name^,version /format:list`) do 2>NUL set "%%I=%%J"
- :: From the output of "wmic bios get version /format:list" set "bios=bios version"
- for /f "tokens=2 delims==" %%I in ('wmic bios get version /format:list') do set "bios=%%I"
- :: From the output of "wmic computersystem get model /format:list" set "model=computer model"
- for /f "tokens=2 delims==" %%I in ('wmic computersystem get model /format:list') do set "model=%%I"
- :: Append to g:\Directory\%COMPUTERNAME% (where %COMPUTERNAME% is an environment variable on the running workstation)
- >>"%prefix%\%COMPUTERNAME%" echo OS Name: %name%
- >>"%prefix%\%COMPUTERNAME%" echo OS Version: %version%
- >>"%prefix%\%COMPUTERNAME%" echo PC Model: %model%
- >>"%prefix%\%COMPUTERNAME%" echo BIOS Version: %bios%
- :: If an environment variable %PROGRAMFILES(x86)% is defined, this is a 64-bit machine.
- if defined PROGRAMFILES(x86) (set arch=X64) else set arch=X86
- :: If %name% does not equal itself with the string "Windows 8" removed, then this is a Windows 8 machine.
- :: See http://www.dostips.com/DtTipsStringManipulation.php for similar examples.
- if "%name%" neq "%name:Windows 8=%" (
- set out=%prefix%\Win8Comps.txt
- ) else if "%name%" neq "%name:Windows 7=%" (
- set out=%prefix%\Win7Comps.txt
- ) else if "%name%" neq "%name:Windows Vista=%" (
- set out=%prefix%\WinVistaComps.txt
- ) else if "%name%" neq "%name:Windows XP=%" (
- set out=%prefix%\WinXPComps.txt
- )
- :: Append to G:\Directory\Win8Comps.txt or similar
- >>"%out%" echo %COMPUTERNAME% is running %name% in %arch% environment
Add Comment
Please, Sign In to add comment