{"id":65053,"date":"2007-04-18T21:17:00","date_gmt":"2007-04-18T21:17:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2007\/04\/18\/how-can-i-tell-which-version-of-quicktime-is-installed-on-a-computer\/"},"modified":"2007-04-18T21:17:00","modified_gmt":"2007-04-18T21:17:00","slug":"how-can-i-tell-which-version-of-quicktime-is-installed-on-a-computer","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-tell-which-version-of-quicktime-is-installed-on-a-computer\/","title":{"rendered":"How Can I Tell Which Version of QuickTime is Installed on a Computer?"},"content":{"rendered":"<p><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" border=\"0\" alt=\"Hey, Scripting Guy! Question\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" height=\"34\"> \n<P>Hey, Scripting Guy! How can I tell whether or not QuickTime is installed on a computer, and, if so, which version is installed?<BR><BR>&#8212; IU<\/P><IMG border=\"0\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" height=\"5\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" border=\"0\" alt=\"Hey, Scripting Guy! Answer\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" height=\"34\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" border=\"0\" alt=\"Script Center\" align=\"right\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" height=\"288\"><\/A> \n<P>Hey, IU. You know, for some reason this column suddenly seems to have become a daily dancing column rather than a daily scripting column. After all, <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/resources\/qanda\/apr07\/hey0417.mspx\"><B>just yesterday<\/B><\/A> we recapped the Scripting Son\u2019s \u2026 dancing \u2026 exploits at his cousin\u2019s wedding. And now, today, the Scripting Guy who writes this column was getting a cup of coffee when he noticed an ad for tango lessons. Learn how to tango, said the ad, and you\u2019ll be able to go into \u201c \u2026 any major city and dance \u2013 no partner required!\u201d<\/P>\n<P>We have to admit that, at first, this sounded like a pretty good deal, and we were all ready to sign up. But then we realized something: the Scripting Guys apparently don\u2019t even<I> need <\/I>tango lessons. Go into any major city and <I>not<\/I> find someone who\u2019d be willing to dance with you? That\u2019s not much of a problem for the Scripting Guys; we don\u2019t really need lessons on how <I>not<\/I> to get people to do anything with us.<\/P>\n<P>On top of that, we\u2019re a bit skeptical about this whole tango thing. Throughout his entire life the Scripting Guy who writes this column has been told that it takes <I>two<\/I> to tango. And now they\u2019re telling him that no partner is required, that apparently it only takes <I>one<\/I> to tango. We\u2019ll believe it when we see it.<\/P>\n<P>Although we hope we never see <I>any<\/I> of the Scripting Guys doing the tango.<\/P>\n<P>No, not even Peter. In fact, <I>especially<\/I> not Peter.<\/P>\n<P>On the other hand, what we <I>would<\/I> like to see is the same thing IU would like to see: a script that can tell you whether or not QuickTime is installed on a computer. You know, a script similar to this one:<\/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 _\n    (&#8220;Select * From Win32_Product Where Name = &#8216;QuickTime'&#8221;)<\/p>\n<p>If colItems.Count = 0 Then\n    Wscript.Echo &#8220;QuickTime is not installed on this computer.&#8221;\nElse\n    For Each objItem in colItems\n        Wscript.Echo &#8220;QuickTime version: &#8221; &amp; objItem.Version\n    Next\nEnd If\n<\/PRE>\n<P>As you can see, determining whether or not QuickTime is installed on a computer is even easier than doing the tango. (Or so we assume, having never actually <I>done<\/I> the tango.) As you can see, we start out by connecting to the WMI service on the local computer. However, like most WMI scripts, we can also use this one to determine whether or not QuickTime has been installed on a remote machine. How do we do that? Simple; we just assign the name of the remote computer (e.g., atl-ws-01) to the variable strComputer:<\/P><PRE class=\"codeSample\">strComputer = &#8220;atl-ws-01&#8221;\n<\/PRE>\n<P>After making the connection we then use this line of code to retrieve a list of all the installed software that has a <B>Name<\/B> with the value <I>QuickTime<\/I>:<\/P><PRE class=\"codeSample\">Set colItems = objWMIService.ExecQuery _\n    (&#8220;Select * From Win32_Product Where Name = &#8216;QuickTime'&#8221;)\n<\/PRE>\n<P>Like we said, this returns a collection consisting of every application installed on the computer that has the name <I>QuickTime<\/I>. Now, suppose we don\u2019t actually have QuickTime installed. That\u2019s fine; in that case we simply get back a collection consisting of 0 items. In turn, that means we can identify whether or not QuickTime is installed simply by checking the number of items in the returned collection, something we do by examining the value of the collection\u2019s <B>Count<\/B> property:<\/P><PRE class=\"codeSample\">If colItems.Count = 0 Then\n<\/PRE>\n<P>If Count is equal to 0 that means that QuickTime is not installed; therefore we echo back a message to that effect:<\/P><PRE class=\"codeSample\">Wscript.Echo &#8220;QuickTime is not installed on this computer.&#8221;\n<\/PRE>\n<P>Logically enough, that also means that, if the Count is<I> greater <\/I>than 0, then QuickTime must be installed. In that case we set up a For Each loop to loop through all the items in the collection and, for each item, echo back the value of the <B>Version<\/B> property:<\/P><PRE class=\"codeSample\">For Each objItem in colItems\n    Wscript.Echo &#8220;QuickTime version: &#8221; &amp; objItem.Version\nNext\n<\/PRE>\n<P>That\u2019s going to be a value similar to this:<\/P><PRE class=\"codeSample\">7.1.5.120\n<\/PRE>\n<P>And there you have it: with that you\u2019ll get back the version of QuickTime installed on the computer, and everyone will be happy.<\/P>\n<P>Well, except maybe those people running Windows Server 2003. By default the Win32_Product class isn\u2019t installed on Windows 2003; unless you\u2019ve gone ahead and added this class (which can be done through <B>Add or Remove Programs<\/B>) this script won\u2019t do you any good. But everyone else will be happy.<\/P>\n<P>Well, except maybe those people running Windows Vista. As it turns out, the Win32_Product class <I>is<\/I> installed by default on Windows Vista; it\u2019s even been enhanced with some additional properties. However, there are some known problems with Win32_Product class on Windows Vista: sometimes it doesn\u2019t work at all (returning an error) and sometimes it works, but a bit more slowly than you might expect (or like). For example, that little script that tells us whether or not QuickTime is installed might take a minute (or even more) to complete.<\/P>\n<P>If it\u2019s any consolation, we agree with you.<\/P>\n<P>So is there another way to determine whether or not QuickTime is installed and, if so, which version is installed? As a matter of fact there are a couple of workarounds that we know of. For example, if you\u2019re performing this check as part of a logon script you can use this little script instead:<\/P><PRE class=\"codeSample\">On Error Resume Next<\/p>\n<p>Set objQuickTime = CreateObject(&#8220;QuickTimeCheckObject.QuickTimeCheck.1&#8221;)<\/p>\n<p>If Err &lt;&gt; 0 Then\n    Wscript.Echo &#8220;QuickTime is not installed on this computer.&#8221;\nElse\n    Wscript.Echo &#8220;QuickTime version: &#8221; &amp; Hex(objQuickTime.QuickTimeVersion)\nEnd If\n<\/PRE>\n<P>Here we\u2019re trying to create an instance of the <B>QuickTime.QuickTimeCheck.1<\/B> object. If the object cannot be created that means that QuickTime is not installed, and we echo back a message to that effect. If the object <I>can<\/I> be created we then grab the value of the <B>Version<\/B> property, convert that to a hexadecimal number, and then echo back the result:<\/P><PRE class=\"codeSample\">Wscript.Echo &#8220;QuickTime version: &#8221; &amp; Hex(objQuickTime.QuickTimeVersion)\n<\/PRE>\n<P>Why do we need to convert the value to a hexadecimal number? Beats us; we just have to. That\u2019s because the Version comes back as a value like 118849536; converting that to a hex value results in a version number of 7158000. Is that good? Yes; on our test machine we happen to be running QuickTime 7.1.5.<\/P>\n<TABLE id=\"EFG\" class=\"dataTable\" cellSpacing=\"0\" cellPadding=\"0\">\n<THEAD><\/THEAD>\n<TBODY>\n<TR class=\"record\" vAlign=\"top\">\n<TD>\n<P class=\"lastInCell\"><B>Note<\/B>. Why does this come back, in effect, as 7.1.5.8000 and the version reported by Win32_Product come back as 7.1.5.120? We don\u2019t know. But <B>7.1.5<\/B> is the official version number reported through the QuickTime UI so we aren\u2019t going to worry about the discrepancy.<\/P><\/TD><\/TR><\/TBODY><\/TABLE>\n<DIV class=\"dataTableBottomMargin\"><\/DIV>\n<P>Unfortunately, though, we have a problem with this script, too: the QuickTime.QuickTimeCheck.1 object can\u2019t be created remotely. (That\u2019s why we included the stipulation about performing this check as part of a logon script.) If you need to perform this task remotely you can, instead, read the value from the registry:<\/P><PRE class=\"codeSample\">HKEY_LOCAL_MACHINE = &amp;H80000002<\/p>\n<p>strComputer = &#8220;.&#8221;<\/p>\n<p>Set objReg = GetObject(&#8220;winmgmts:\\\\&#8221; &amp; strComputer &amp; &#8220;\\root\\default:StdRegProv&#8221;)<\/p>\n<p>strKeyPath = &#8220;Software\\Apple Computer, Inc.\\QuickTime&#8221;\nValueName = &#8220;Version&#8221;<\/p>\n<p>objReg.GetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath, ValueName, dwValue<\/p>\n<p>If IsNull(dwValue) Then\n    Wscript.Echo &#8220;QuickTime is not installed.&#8221;\nElse\n    Wscript.Echo &#8220;QuickTime version: &#8221; &amp; Hex(dwValue)\nEnd If\n<\/PRE>\n<P>This script should work on <I>any<\/I> version of Windows. So then why didn\u2019t we just show you this particular script in the first place? Well, in general, we\u2019re hesitant about using scripts that read directly from the registry; after all, there\u2019s no guarantee that the registry path will remain the same when the next version of QuickTime is released. For that matter, we can\u2019t even guarantee that this script will work with <I>previous<\/I> versions of QuickTime. That\u2019s why, whenever possible, it\u2019s better to let a WMI class such as Win32_Product do all the work rather than try and retrieve these values from the registry. <I>(Editor\u2019s Note: Another reason? On the Scripting Editor\u2019s computer, the UI and Win32_Product report a version of 7.0.3; the check of the QuickTime.QuickTimeCheck.1 object returns 7038000; the registry returns 70<\/I><B><I>2<\/I><\/B><I>8000.)<\/I> But, like they say, desperate times call for desperate measures. And, as in this case, sort of, kind of desperate times call for sort of, kind of desperate measures.<\/P>\n<P>If that sounds like we\u2019re trying to dance around the problem, well, to a certain extent we are. But at least that gives you an alternative approach just in case you run into problems with the Win32_Product class. And we promise that this is the <I>only<\/I> dancing you\u2019ll ever see from the Scripting Guys, even when they attend <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/newswire\/news0307.htm\"><B>TechEd 2007<\/B><\/A> this coming June. For one thing, the Scripting Guy who writes this column doesn\u2019t dance, period. For another, after her <A href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/topics\/mms2007\/tuesday.mspx\"><B>near-tragic incident<\/B><\/A> in San Diego, we\u2019ve been discouraging Scripting Guy Jean Ross from doing things that are just too difficult for her. \u201cDo your walking first,\u201d we tell her, \u201cand <I>then<\/I> chew your gum.\u201d With any luck she\u2019ll listen to us this time. <I>(Editor\u2019s Note: Could it be that the Scripting Guy who writes this column is looking out for the well-being of a fellow Scripting Guy? Don\u2019t believe it; he\u2019s really just concerned that Scripting Guy Jean Ross will embarrass <\/I>him<I>. Which is entirely possible \u2013 even likely.)<\/I><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! How can I tell whether or not QuickTime is installed on a computer, and, if so, which version is installed?&#8212; IU Hey, IU. You know, for some reason this column suddenly seems to have become a daily dancing column rather than a daily scripting column. After all, just yesterday we recapped the [&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":[16,47,3,4,5,6],"class_list":["post-65053","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-desktop-management","tag-general-management-tasks","tag-scripting-guy","tag-scripting-techniques","tag-vbscript","tag-wmi"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! How can I tell whether or not QuickTime is installed on a computer, and, if so, which version is installed?&#8212; IU Hey, IU. You know, for some reason this column suddenly seems to have become a daily dancing column rather than a daily scripting column. After all, just yesterday we recapped the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65053","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=65053"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65053\/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=65053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=65053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=65053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}