{"id":2724,"date":"2018-11-07T12:03:44","date_gmt":"2018-11-07T11:03:44","guid":{"rendered":"https:\/\/eskerahn.dk\/?p=2724"},"modified":"2024-03-05T01:51:39","modified_gmt":"2024-03-05T00:51:39","slug":"windows-oddity-with-schtasks-exe-and-falsely-reported-error","status":"publish","type":"post","link":"https:\/\/eskerahn.dk\/?p=2724","title":{"rendered":"Windows oddity: Schtasks.exe falsely reported error. Workaround."},"content":{"rendered":"<p>If you run a command like this it works fine to any remote machine<\/p>\n<pre>    schtasks.exe \/query \/s SomePC \/U MyAccount \/P XXXXX<\/pre>\n<p>If you try to let it point back to your own machine you get an error-message<\/p>\n<pre>    ERROR: User credentials are not allowed on the local machine.<\/pre>\n<p>BUT this is actually FALSE!!! I found a workaround though..<\/p>\n<p><!--more--><\/p>\n<p>You get the same message whether you are pointing by name (with or without domain), a real IP, 127.0.0.1 or &#8220;localhost&#8221;.<\/p>\n<p>IF you get the crazy idea and add an entry to your <code>\\Windows\\System32\\Drivers\\etc\\Host.<\/code> file, that has your pc&#8217;s IP and any name, e.g.<\/p>\n<pre>    1.2.3.4\u00a0\u00a0 MyOwnPCAlias.Something.Never.Used<\/pre>\n<p>THEN the command works with that IP\u00a0 &#8211; but still not with the rest (nor the alias)<\/p>\n<pre>    schtasks.exe \/query \/s 1.2.3.4 \/U MyAccount \/P XXXXX<\/pre>\n<p>This trick proves that it is NOT a limitation in the WinRM protocol nor <code>schtasks.exe<\/code>, but an erroneous error message, as someone prohibited something that actually technically works just fine&#8230; (And is useful with other credentials!)<\/p>\n<p>With the trick I guess the program makes a reverse lookup on the IP, and detect it as not the current pc name, and then proceeds processing the call through WinRM and not locally&#8230;<\/p>\n<p>The bug and trick goes for both stand-alone machines and machines in a domain. (Only works for real IP not 127.0.0.1 though)<\/p>\n<p>&nbsp;<\/p>\n<p>I stumbled upon it inventorying a range of PC&#8217;s with an administrative account, and found I was prohibited from querying the running machine with <code>schtasks.exe<\/code> , and in a desperate attempt I tried an alias. Only to detect that did not work either, but then accidentally executed with the IP again before removing the Hosts entry&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you run a command like this it works fine to any remote machine schtasks.exe \/query \/s SomePC \/U MyAccount \/P XXXXX If you try to let it point back to your own machine you get an error-message ERROR: User credentials are not allowed on the local machine. BUT this is actually FALSE!!! I found [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-2724","post","type-post","status-publish","format-standard","hentry","category-pc-and-code-samples"],"_links":{"self":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/2724","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2724"}],"version-history":[{"count":6,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/2724\/revisions"}],"predecessor-version":[{"id":5423,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=\/wp\/v2\/posts\/2724\/revisions\/5423"}],"wp:attachment":[{"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2724"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2724"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eskerahn.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2724"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}