{"id":7147,"date":"2014-04-02T05:00:00","date_gmt":"2014-04-02T13:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=7147"},"modified":"2014-04-01T15:23:25","modified_gmt":"2014-04-01T23:23:25","slug":"microsoft-windows-8-1-breaks-version-api","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/04\/02\/microsoft-windows-8-1-breaks-version-api\/","title":{"rendered":"Microsoft Windows 8.1 breaks version API."},"content":{"rendered":"<p>If we need to check what Windows version a PowerShell script run on, we usually use a statement like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"Shell\" alt=\"Shell\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/Shell.png\" width=\"499\" height=\"180\" border=\"0\" \/><\/p>\n<p>So imagine our surprise when we saw what happens when you run this as a script in PrimalScript:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"PrimalScript\" alt=\"PrimalScript\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/PrimalScript.png\" width=\"409\" height=\"205\" border=\"0\" \/><\/p>\n<p>Instead of reporting the actual Windows version, it appears as if we are running in Windows 8 instead of 8.1<br \/>\nTo make sure we didn\u2019t have a glitch in PrimalScript (and because we didn\u2019t quite trust our eyes), we packaged the script as an executable and ran that.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"Packaged\" alt=\"Packaged\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/Packaged.png\" width=\"548\" height=\"180\" border=\"0\" \/><\/p>\n<p>Same result, it reports the incorrect version number.<\/p>\n<p>According to Microsoft this is intentional:<\/p>\n<p><a title=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dn302074(v=vs.85).aspx\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dn302074(v=vs.85).aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/dn302074(v=vs.85).aspx<\/a><\/p>\n<p>Before you ask, we have no idea what could possibly possess Microsoft to break such a fundamental API call so that it reports an incorrect version.<\/p>\n<p>As shown on the web page we linked to above, you have to tag your executable in a manifest as supporting Windows 8.1 in order to get a correct version number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"Custom manifest\" alt=\"Custom manifest\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/Custommanifest.png\" width=\"555\" height=\"480\" border=\"0\" \/><\/p>\n<p>In the packager settings you have to switch to a custom manifest and and specify the manifest file.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"Settings\" alt=\"Settings\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/Settings.png\" width=\"640\" height=\"399\" border=\"0\" \/><\/p>\n<p>If you follow this patch and re-package the executable it will now report the correct version number.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"With Manifest\" alt=\"With Manifest\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/04\/WithManifest.png\" width=\"625\" height=\"252\" border=\"0\" \/><\/p>\n<p>Needless to say, we will update our default manifest and the packager to accommodate this latest \u201cit\u2019s not a bug, it\u2019s a feature\u201d play by Microsoft in the next service build.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If we need to check what Windows version a PowerShell script run on, we usually use a statement like this: So imagine our surprise when we saw what happens when you run this as a script in PrimalScript: Instead of reporting the actual Windows version, it appears as if we are running in Windows 8 [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,410,21,25],"tags":[553,897,898,28,1016,37,899],"class_list":["post-7147","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-primalscript-software-news","category-software-news","category-windows-powershell","tag-api","tag-getversion","tag-osversion","tag-powershell","tag-powershell-studio","tag-primalscript","tag-windows-8-1"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=7147"}],"version-history":[{"count":3,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7147\/revisions"}],"predecessor-version":[{"id":7150,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7147\/revisions\/7150"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=7147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=7147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=7147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}