Question : How can I get the windows version from a dos prompt

I need to get the Operating system (XP, Vista, or Windows 7) from a dos prompt as well as the "version" (32bit or 64bit) how can I do that?

I'm creating a batch file that will backup other files and need to create a variable like %osys% (This would be the operating system Windows XP, Vista, or 7) and %version% (This would be 32 or 64)

Answer : How can I get the windows version from a dos prompt

Depending on what you are looking for the SYSTEMINFO command can be a great source of information as well.  Run the command from a prompt to get a sense for the information available.  In a batch file, here are a couple of commands to extract the OS Name and OS Version.

for /f "tokens=1-2*" %%A in ('systeminfo 2^>NUL ^|find "OS Name:"') do set osname=%%C
for /f "tokens=1-2*" %%A in ('systeminfo 2^>NUL ^|find "OS Version:"') do set osver=%%C
echo %osname%
echo %osver%

~bp
Random Solutions  
 
programming4us programming4us