{"id":401,"date":"2023-02-04T19:47:10","date_gmt":"2023-02-04T19:47:10","guid":{"rendered":"https:\/\/xuan.co.uk\/?p=401"},"modified":"2023-07-17T20:55:51","modified_gmt":"2023-07-17T20:55:51","slug":"here-is-a-one-line-batch-script-in-ms-dos-command-to-check-the-elevated-status-and-exit-the-script-if-the-user-is-not-an-administrator","status":"publish","type":"post","link":"https:\/\/xuan.co.uk\/?p=401","title":{"rendered":"Here is a one-line batch script in MS-DOS command to check the elevated status and exit the script if the user is not an administrator."},"content":{"rendered":"<p>net session &gt;nul 2&gt;&amp;1 || exit<\/p>\n<p>&nbsp;<\/p>\n<p>This script runs the net session command, which returns an error message if the user is not an administrator. The || operator allows the script to execute the exit command if the previous command returns an error code. The &gt;nul 2&gt;&amp;1 redirects the output of the net session command to null so that it doesn&#8217;t display any error messages on the screen.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>net session &gt;nul 2&gt;&amp;1 || exit &nbsp; This script runs the net session command, which returns an error message if the user is not an administrator. The || operator allows the script to execute the exit command if the previous command returns an error code. The &gt;nul 2&gt;&amp;1 redirects the <a class=\"more-link\" href=\"https:\/\/xuan.co.uk\/?p=401\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[85,81],"class_list":["post-401","post","type-post","status-publish","format-standard","hentry","category-tech-tips","tag-admin-check","tag-cmd"],"_links":{"self":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401"}],"version-history":[{"count":1,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xuan.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}