1

I'm making some batch files to personalise my windows installations faster, but I need my batch to take a road depending on which Windows version it's running on.

If i could get the windows version into a variable i could build a conditional to take the right path.

I've been looking for an answer on google and even here but... the answers i've got dont meet what i need.

could someone help me please?...

Brlesskoin
  • 21
  • 1
  • 2
  • 1
    Welcome to Super User! Please note that [SU] is not a script writing service. If you tell us what you have tried so far (including any scripts you are using) and where you are stuck then we can try to help with specific problems. You should also read [How do I ask a good question?](http://superuser.com/help/how-to-ask). – DavidPostill Apr 05 '16 at 22:26
  • You haven't defined your need. What do you mean by **version**? Are you looking for a string like "Microsoft Windows 7 Home Premium" or a number like "6.1.7601"? What do you expect this **version** to look like? Give examples! [edit] this into your question. – DavidPostill Apr 05 '16 at 22:30
  • http://stackoverflow.com/questions/7330187/how-to-find-the-windows-version-from-the-powershell-command-line – picobit Apr 05 '16 at 22:52
  • Guys i'm so sorry didnt meant to abuse... look this is what I have!: @echo off setlocal for /f "tokens=4-7 delims=. " %%i in ('ver') do set VERSION=%%i.%%j if "%version%" == "10.0" echo Windows 10 pause endlocal pause – Brlesskoin Apr 11 '16 at 13:14
  • 1
    Does this answer your question? [How to get the ACTUAL version number for Windows 10 from command line? (NOT build number!)](https://superuser.com/questions/1519110/how-to-get-the-actual-version-number-for-windows-10-from-command-line-not-buil) – Ramhound Feb 20 '20 at 00:07

1 Answers1

1

If you're looking for the version number, that has been answered here: https://stackoverflow.com/a/13212088/1337519

C:\Users\somedude>wmic os get version
Version
6.1.7601

C:\Users\somedude>

and here: https://stackoverflow.com/a/13212116/1337519

@echo off
setlocal
for /f "tokens=4-5 delims=. " %%i in ('ver') do set VERSION=%%i.%%j
if "%version%" == "6.3" echo Windows 8.1
if "%version%" == "6.2" echo Windows 8.
if "%version%" == "6.1" echo Windows 7.
if "%version%" == "6.0" echo Windows Vista.
rem etc etc
endlocal
geniusburger
  • 121
  • 3
  • `for /f "skip=2 tokens=2,*" %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentBuildNumber') do (set VERSION=%%B)` should also do the trick – mirh Jul 26 '18 at 20:46