{"id":64023,"date":"2007-09-14T02:04:00","date_gmt":"2007-09-14T02:04:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2007\/09\/14\/how-can-i-determine-which-version-of-windows-vista-is-installed-on-a-computer\/"},"modified":"2007-09-14T02:04:00","modified_gmt":"2007-09-14T02:04:00","slug":"how-can-i-determine-which-version-of-windows-vista-is-installed-on-a-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-determine-which-version-of-windows-vista-is-installed-on-a-computer\/","title":{"rendered":"How Can I Determine Which Version of Windows Vista is Installed on a Computer?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" height=\"34\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"> \n<P>Hey, Scripting Guy! How can I determine which version of Windows Vista is installed on a computer?<BR><BR>&#8212; GC<\/P><IMG height=\"5\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" border=\"0\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" height=\"34\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" height=\"288\" alt=\"Script Center\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" align=\"right\" border=\"0\"><\/A> \n<P>Hey, GC. You know, Microsoft is one of the largest and most successful companies the world has ever known. And yet, despite all our successes, we\u2019re really no different than any anyone else: for example, from time-to-time we get a little jealous of other companies and what <I>they<\/I> have achieved. But that\u2019s understandable after all, for years we Microsoft employees have had to endure the indignity of driving past <A href=\"http:\/\/baskinrobbins.com\/\" target=\"_blank\"><B>Baskin-Robbins ice cream stores<\/B><\/A> and seeing the sign advertising their 31 different flavors of ice cream. <I>Thirty-one different flavors<\/I>! How in the world can we compete with <I>that<\/I>?<\/P>\n<P>But, then again, we <I>are<\/I> Microsoft. You say that Baskin-Robbins has 31 different flavors of ice cream? Good for them; just wait and see how many different flavors of Windows Vista <I>we<\/I> can release. Let\u2019s see, there\u2019s Windows Vista Home Basic and Windows Vista Home Premium. There\u2019s Windows Vista Enterprise edition, Windows Vista Ultimate, Windows Vista White Chocolate and Macadamia Nuts. There\u2019s \u2013 well, you get the idea. Thanks to Windows Vista, all us Microsoft employees can now drive past Baskin-Robbins with our heads held high.<\/P>\n<TABLE class=\"dataTable\" id=\"ETD\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. OK, technically some of us don\u2019t actually drive <I>past<\/I> a Baskin-Robbins; instead, we pull in and order two or three scoops of Chocolate Fudge ice cream. But you know what we mean.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>As a general rules, more choices are better than fewer choices, on the other hand, it\u2019s also true that having 31 flavors of Windows Vista can complicate life for system administrators. This is especially true in light of the fact that these different flavors of Vista have different capabilities. (For example, do you want BitLocker drive encryption? Then you need to install Windows Vista Ultimate.) But how in the world can you determine whether or not a computer is even running Windows Vista, let alone which <I>flavor<\/I> of Vista that computer is running?<\/P>\n<P>Funny you should ask:<\/P><PRE class=\"codeSample\">strComputer = &#8220;.&#8221;<\/p>\n<p>Set objWMIService = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\cimv2&#8221;)<\/p>\n<p>Set colItems = objWMIService.ExecQuery(&#8220;Select * From Win32_OperatingSystem&#8221;)<\/p>\n<p>For Each objItem in colItems\n    If Instr(objItem.Caption, &#8220;Vista&#8221;) Then\n        Select Case objItem.OperatingSystemSKU\n             Case 0 strVersion = &#8220;Undefined.&#8221;\n             Case 1 strVersion = &#8220;Ultimate Edition.&#8221; \n             Case 2 strVersion = &#8220;Home Basic Edition.&#8221; \n             Case 3 strVersion = &#8220;Home Basic Premium Edition.&#8221; \n             Case 4 strVersion = &#8220;Enterprise Edition.&#8221; \n             Case 5 strVersion = &#8220;Home Basic N Edition.&#8221; \n             Case 6 strVersion = &#8220;Business Edition.&#8221; \n             Case 7 strVersion = &#8220;Standard Server Edition.&#8221; \n             Case 8 strVersion = &#8220;Datacenter Server Edition.&#8221; \n             Case 9 strVersion = &#8220;Small Business Server Edition.&#8221; \n             Case 10 strVersion = &#8220;Enterprise Server Edition.&#8221; \n             Case 11 strVersion = &#8220;Starter Edition.&#8221; \n             Case 12 strVersion = &#8220;Datacenter Server Core Edition.&#8221; \n             Case 13 strVersion = &#8220;Standard Server Core Edition.&#8221; \n             Case 14 strVersion = &#8220;Enterprise Server Core Edition.&#8221; \n             Case 15 strVersion = &#8220;Enterprise Server IA64 Edition.&#8221; \n             Case 16 strVersion = &#8220;Business N Edition.&#8221; \n             Case 17 strVersion = &#8220;Web Server Edition.&#8221; \n             Case 18 strVersion = &#8220;Cluster Server Edition.&#8221; \n             Case 19 strVersion = &#8220;Home Server Edition.&#8221; \n             Case 20 strVersion = &#8220;Storage Express Server Edition.&#8221; \n             Case 21 strVersion = &#8220;Storage Standard Server Edition.&#8221; \n             Case 22 strVersion = &#8220;Storage Workgroup Server Edition.&#8221; \n             Case 23 strVersion = &#8220;Storage Enterprise Server Edition.&#8221; \n             Case 24 strVersion = &#8220;Server For Small Business Edition.&#8221; \n             Case 25 strVersion = &#8220;Small Business Server Premium Edition.&#8221; \n        End Select\n        Wscript.Echo &#8220;This computer is running Windows Vista &#8221; &amp; strVersion\n    Else\n        Wscript.Echo &#8220;This computer is not running Windows Vista.&#8221;\n    End If\nNext  \n<\/PRE>\n<P>What\u2019s that? Can we explain how this script work? You know what? Not only <I>can<\/I> we explain how this script, we <I>will<\/I> explain how this script works.<\/P>\n<TABLE class=\"dataTable\" id=\"EQE\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. Which, we might add, puts us yet another step ahead of Baskin-Robbins. How often do the folks at Baskin-Robbins offer to tell you how they make their Old-Fashioned Butter Pecan Ice Cream?<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>The script starts out by connecting to the WMI service on the local computer. Can we run this same script against a <I>remote<\/I> computer? Of course we can; after all, the script wouldn\u2019t be particularly useful if you couldn\u2019t. To run this script against a remote computer (and thus determine the flavor of Vista running on that remote machine), simply assign the name of the remote computer to the variable strComputer:<\/P><PRE class=\"codeSample\">strComputer = &#8220;atl-ws-01&#8221;\n<\/PRE>\n<TABLE class=\"dataTable\" id=\"EBF\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. Yes, you can also run this script against an entire flock of computers (e.g., all the computers in an OU or all the computers listed in a text file). For sample code take a peek at our <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/scripts\/templates\/default.mspx\"><B>Multiple\/Remote Computer Scripting Templates<\/B><\/A>.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>After we connect to the WMI service we then call the <B>ExecQuery<\/B> method and return a collection of all the operating systems currently in use on the computer:<\/P><PRE class=\"codeSample\">Set colItems = objWMIService.ExecQuery(&#8220;Select * From Win32_OperatingSystem&#8221;)\n<\/PRE>\n<P>Admittedly, there will only be one item in the collection; that\u2019s because only one operating system can be in use at any given time. However, because this <I>is<\/I> a collection we still need to set up a For Each loop to loop through each and every operating system in the collection:<\/P><PRE class=\"codeSample\">For Each objItem in colItems \n<\/PRE>\n<P>And what are we going to do inside that loop? Well, the first thing we\u2019re going to do is determine whether or not our computer is running <I>any<\/I> flavor of Windows Vista. That\u2019s what this line of code is for:<\/P><PRE class=\"codeSample\">If Instr(objItem.Caption, &#8220;Vista&#8221;) Then\n<\/PRE>\n<P>All we\u2019re doing here is looking at the value of the operating system\u2019s <B>Caption<\/B> property and checking to see if the word <I>Vista<\/I> appears anywhere within that caption. (That\u2019s what the <B>InStr<\/B> function does; it checks to see if a given substring can be found anywhere inside a string value.) If InStr returns a 0 that means that the word the <I>Vista<\/I> couldn\u2019t be found anywhere in the Caption. In that case, we assume that the computer is <I>not<\/I> running Windows Vista, and we echo back the appropriate message:<\/P><PRE class=\"codeSample\">Wscript.Echo &#8220;This computer is not running Windows Vista.&#8221;\n<\/PRE>\n<P>But suppose InStr returns a value <I>other<\/I> than 0; for example, suppose our operating system caption is this:<\/P><PRE class=\"codeSample\">Microsoft Windows Vista Enterprise\n<\/PRE>\n<P>In that case, that means that the computer <I>is<\/I> running Windows Vista. And, in turn, that means we need to try and determine which version of Vista we\u2019re dealing with.<\/P>\n<P>But don\u2019t worry: we don\u2019t have to write some code that tries to tease the word <I>Enterprise<\/I> out of the Caption property. Instead, we use a brand-new property added to the Win32_OperatingSystem class: <B>OperatingSystemSKU<\/B>. The OperatingSystemSKU property returns an integer value that identifies the \u201cSKU\u201d (stock-keeping unit) for the flavor of Vista running on the computer. Admittedly, we could just report back one of these integer values (e.g., a 4 for a computer running Windows Vista Enterprise edition); that\u2019s probably what Baskin-Robbins would do. But Microsoft is <I>not<\/I> Baskin-Robbins.<\/P>\n<TABLE class=\"dataTable\" id=\"EMH\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD class=\"\">\n<P class=\"lastInCell\"><B>Note<\/B>. Do the Scripting Guys <I>wish<\/I> Microsoft was Baskin-Robbins? We probably shouldn\u2019t answer that question \u2026.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Because we <I>are<\/I> Microsoft, however, we\u2019ve taken the extra step and set up a Select Case statement that determines the value of the OperatingSystemSKU property and then assigns the corresponding operating system flavor to a variable named strVersion. For example, if the OperatingSystemSKU really <I>does<\/I> return the value 4, then the following line of code is executed (and the value gets assigned to the variable strVersion):<\/P><PRE class=\"codeSample\">Case 4 strVersion = &#8220;Enterprise Edition.&#8221; \n<\/PRE>\n<P>After we dispose of the Select Case block all that\u2019s to do is run the following line of code:<\/P><PRE class=\"codeSample\">Wscript.Echo &#8220;This computer is running Windows Vista &#8221; &amp; strVersion\n<\/PRE>\n<P>In turn, that\u2019s going to cause a message similar to this one to appear onscreen:<\/P><PRE class=\"codeSample\">This computer is running Windows Vista Enterprise Edition.\n<\/PRE>\n<P>And there you have it.<\/P>\n<P>Of course, we realize that many of you might be a little worried about Microsoft; after all, having successfully matched Baskin-Robbins flavor-for-flavor, well, maybe we\u2019ll get a little complacent, maybe we\u2019ll just sit back and rest on our laurels. Take it from the Scripting Guys: you have nothing to worry about. True, we now have as many flavors of Vista as Baskin-Robbins does ice cream. On the other hand, Baskin-Robbins still holds the world record for the largest Ice Cream Scoop Pyramid (achieved on May 18, 2000 using 3,100 scoops of ice cream). Does that mean that Microsoft is busy working on a Windows Vista Ice Cream Scoop Pyramid? Well, we\u2019re not allowed to discuss unreleased and unannounced products. At this point in time all we can say is this: at Microsoft, we never back away from a challenge.<\/P>\n<P>Never.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I determine which version of Windows Vista is installed on a computer?&#8212; GC Hey, GC. You know, Microsoft is one of the largest and most successful companies the world has ever known. And yet, despite all our successes, we\u2019re really no different than any anyone else: for example, from time-to-time [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[31,3,5,288,725],"class_list":["post-64023","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-operating-system","tag-scripting-guy","tag-vbscript","tag-version-information","tag-windows-vista"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I determine which version of Windows Vista is installed on a computer?&#8212; GC Hey, GC. You know, Microsoft is one of the largest and most successful companies the world has ever known. And yet, despite all our successes, we\u2019re really no different than any anyone else: for example, from time-to-time [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/64023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=64023"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/64023\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=64023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=64023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=64023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}