Check os version using batch file
I need to get the OS version with a batch file. I 've seen a lot of examples online, many uses something like this code:. It's much easier and faster to get this information by only parsing the output of ver :. This table on MSDN documents which version number corresponds to which Windows product version this is where you get the 6.
The only drawback of this technique is that it cannot distinguish between the equivalent server and consumer versions of Windows. Be aware that the extracted version number does not always corresponds to the Windows name release. See below an extract from the full list of Microsoft Windows versions.
Please also up-vote answers from Agent Gibbs and peterbh as my answer is inspired from their ideas. This will give you the version number in a command line, then you just need to integrate into the batch file. I know it's an old question but I thought these were useful enough to put here for people searching. This first one is a simple batch way to get the right version. You can find out if it is Server or Workstation if that's important in another process. I just didn't take time to add it.
We use this structure inside code to ensure compliance with requirements. I'm sure there are many more graceful ways but this does always work. Here is a VBscript function that provides version info, including if it is the Server vs. So the answers I read here are mostly lengthy. The shortest answer by Alex works good, but not so clean. Above is for command prompt. Here is another variant : some other solutions doesn't work with XP, this one does and was inspired by RLH solution.
This returns the windows version, i. Actually, that one liner doesn't work for windows xp since the ver contains xp in the string. Instead of 5. This will output Version. Sadly, this means the command cannot differentiate between 32bit and 64bit build since it doesn't read the. Hope this helps! You can then combine with the ver command to get exact version.
The Extract the full version x. Pieman Jun 3, at UTC. Krizz This person is a verified professional. Hexx Jun 3, at UTC. Thai Pepper. Robert Jun 3, at UTC. Hendo Jun 3, at UTC.
David wrote: Any reason you're doing this in batch and not powershell?? David Jun 4, at UTC. I would recommend leveraging WMI. Hope this helps. Hendo Feb 3, at UTC. Robert Jun 3, at UTC. Hendo Jun 3, at UTC. David wrote: Any reason you're doing this in batch and not powershell?? David Jun 4, at UTC. I would recommend leveraging WMI. Hope this helps. Hendo Feb 3, at UTC.
Holy Ressurect an Old Thread, Batman! Thanks for the input, but since we've now gottten rid of XP, a tad moot. However, always good to have these tricks tucked away for other uses. I think this is what you are trying to do. Get Windows version in a batch file Posted by: admin December 18, Leave a comment. Have you tried using the wmic commands?
Try wmic os get version This will give you the version number in a command line, then you just need to integrate into the batch file. Extract version x. Version, 3 Select Case strOsVer case "5.
This will return 5. If you are looking to simply show windows version in a batch file such as Windows 10 etc.
0コメント