runas: I can't invoke system commands












1















This works:



$ C:UsersGuest> runas /user:Administrator cmd


Executes a new cmd.exe process/window as Administrator



However using commands like type, cd, echo, dir, etc won't work:



$ C:UsersGuest> runas /user:Administrator type
$ C:UsersGuest> runas /user:Administrator cd
$ C:UsersGuest>
$ C:UsersGuest> echo "hello" > test
$ C:UsersGuest> runas /user:Administrator "type C:UsersGuesttest"


all of the above give the same error:



RUNAS ERROR: Unable to run - type C:UsersGuesttest
2: The system can not find the file specified


enter image description here










share|improve this question





























    1















    This works:



    $ C:UsersGuest> runas /user:Administrator cmd


    Executes a new cmd.exe process/window as Administrator



    However using commands like type, cd, echo, dir, etc won't work:



    $ C:UsersGuest> runas /user:Administrator type
    $ C:UsersGuest> runas /user:Administrator cd
    $ C:UsersGuest>
    $ C:UsersGuest> echo "hello" > test
    $ C:UsersGuest> runas /user:Administrator "type C:UsersGuesttest"


    all of the above give the same error:



    RUNAS ERROR: Unable to run - type C:UsersGuesttest
    2: The system can not find the file specified


    enter image description here










    share|improve this question



























      1












      1








      1








      This works:



      $ C:UsersGuest> runas /user:Administrator cmd


      Executes a new cmd.exe process/window as Administrator



      However using commands like type, cd, echo, dir, etc won't work:



      $ C:UsersGuest> runas /user:Administrator type
      $ C:UsersGuest> runas /user:Administrator cd
      $ C:UsersGuest>
      $ C:UsersGuest> echo "hello" > test
      $ C:UsersGuest> runas /user:Administrator "type C:UsersGuesttest"


      all of the above give the same error:



      RUNAS ERROR: Unable to run - type C:UsersGuesttest
      2: The system can not find the file specified


      enter image description here










      share|improve this question
















      This works:



      $ C:UsersGuest> runas /user:Administrator cmd


      Executes a new cmd.exe process/window as Administrator



      However using commands like type, cd, echo, dir, etc won't work:



      $ C:UsersGuest> runas /user:Administrator type
      $ C:UsersGuest> runas /user:Administrator cd
      $ C:UsersGuest>
      $ C:UsersGuest> echo "hello" > test
      $ C:UsersGuest> runas /user:Administrator "type C:UsersGuesttest"


      all of the above give the same error:



      RUNAS ERROR: Unable to run - type C:UsersGuesttest
      2: The system can not find the file specified


      enter image description here







      windows command-line runas






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 28 at 18:34







      chefarov

















      asked Jan 28 at 17:48









      chefarovchefarov

      1084




      1084






















          1 Answer
          1






          active

          oldest

          votes


















          1














          That is because type and cd are internal commands of the command interpreter, cmd.exe.



          Use



          $ C:UsersGuest> runas /user:Administrator "cmd /c type "C:UsersGuesttest""


          You could call the cd command the same way, but there is no point calling cd in a process that will terminate immediately.






          share|improve this answer
























          • Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

            – chefarov
            Jan 28 at 19:25








          • 1





            That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

            – RalfFriedl
            Jan 28 at 19:51











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399359%2frunas-i-cant-invoke-system-commands%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          That is because type and cd are internal commands of the command interpreter, cmd.exe.



          Use



          $ C:UsersGuest> runas /user:Administrator "cmd /c type "C:UsersGuesttest""


          You could call the cd command the same way, but there is no point calling cd in a process that will terminate immediately.






          share|improve this answer
























          • Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

            – chefarov
            Jan 28 at 19:25








          • 1





            That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

            – RalfFriedl
            Jan 28 at 19:51
















          1














          That is because type and cd are internal commands of the command interpreter, cmd.exe.



          Use



          $ C:UsersGuest> runas /user:Administrator "cmd /c type "C:UsersGuesttest""


          You could call the cd command the same way, but there is no point calling cd in a process that will terminate immediately.






          share|improve this answer
























          • Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

            – chefarov
            Jan 28 at 19:25








          • 1





            That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

            – RalfFriedl
            Jan 28 at 19:51














          1












          1








          1







          That is because type and cd are internal commands of the command interpreter, cmd.exe.



          Use



          $ C:UsersGuest> runas /user:Administrator "cmd /c type "C:UsersGuesttest""


          You could call the cd command the same way, but there is no point calling cd in a process that will terminate immediately.






          share|improve this answer













          That is because type and cd are internal commands of the command interpreter, cmd.exe.



          Use



          $ C:UsersGuest> runas /user:Administrator "cmd /c type "C:UsersGuesttest""


          You could call the cd command the same way, but there is no point calling cd in a process that will terminate immediately.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 28 at 18:31









          RalfFriedlRalfFriedl

          1,128147




          1,128147













          • Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

            – chefarov
            Jan 28 at 19:25








          • 1





            That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

            – RalfFriedl
            Jan 28 at 19:51



















          • Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

            – chefarov
            Jan 28 at 19:25








          • 1





            That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

            – RalfFriedl
            Jan 28 at 19:51

















          Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

          – chefarov
          Jan 28 at 19:25







          Thanks. I managed to use cd in this way: RUNAS /user:Administrator "CMD /K CD C:UsersAdministrator" however it spawns a new shell that way

          – chefarov
          Jan 28 at 19:25






          1




          1





          That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

          – RalfFriedl
          Jan 28 at 19:51





          That is the purpose of the /K option and the only reason to use a CD command, because the shell process doesn't exit immediately.

          – RalfFriedl
          Jan 28 at 19:51


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1399359%2frunas-i-cant-invoke-system-commands%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Index of /

          Tribalistas

          Listed building