{"id":1100,"date":"2014-07-04T09:57:08","date_gmt":"2014-07-04T09:57:08","guid":{"rendered":"http:\/\/scunster.co.uk\/?p=1100"},"modified":"2014-07-04T09:58:05","modified_gmt":"2014-07-04T09:58:05","slug":"ensure-that-a-windows-batch-file-is-run-as-adminstrator","status":"publish","type":"post","link":"https:\/\/scunster.co.uk\/?p=1100","title":{"rendered":"Ensure that a Windows batch file is run as Adminstrator"},"content":{"rendered":"<p>It is sometimes necessary to run Windows batch files as an Administrator. While this in itself isn&#8217;t possible 100% because of the obvious security risks, it is do-able!<\/p>\n<p>Simply add this to the beginning of your bat file:<\/p>\n<pre>set IS_ELEVATED=0\r\nwhoami \/groups | findstr \/b \/c:&amp;quot;Mandatory Label\\High Mandatory Level&amp;quot; | findstr \/c:&amp;quot;Enabled group&amp;quot; &amp;gt; nul: &amp;amp;&amp;amp; set IS_ELEVATED=1\r\nif %IS_ELEVATED%==0 (\r\ncls\r\necho You must run the command prompt as administrator to install.\r\npause 5\r\nexit \/b 1\r\n)<\/pre>\n<p>Every time the batch file is run as a non administrator it will display a message that you need to run as administrator and close itself upon a keypress<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is sometimes necessary to run Windows batch files as an Administrator. While this in itself isn&#8217;t possible 100% because of the obvious security risks, it is do-able! Simply add this to the beginning of your bat file: set IS_ELEVATED=0 whoami \/groups | findstr \/b \/c:&amp;quot;Mandatory Label\\High Mandatory Level&amp;quot; | findstr \/c:&amp;quot;Enabled group&amp;quot; &amp;gt; nul: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[169,17],"tags":[],"class_list":["post-1100","post","type-post","status-publish","format-standard","hentry","category-win-7-10-tips-tricks","category-windows"],"_links":{"self":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1100"}],"version-history":[{"count":2,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1100\/revisions"}],"predecessor-version":[{"id":1102,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1100\/revisions\/1102"}],"wp:attachment":[{"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scunster.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}