1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

batch file with runas not behaving as expected

Discussion in 'DOS/Other' started by fatal_lordes, Mar 30, 2010.

Thread Status:
Not open for further replies.
  1. fatal_lordes

    fatal_lordes Thread Starter

    Joined:
    Mar 30, 2010
    Messages:
    1
    Hi all

    I've written a batch file that uses the runas command. The command I've used works when I test it in CMD less the runas part but when it's in the batch file and I use the runas part, it works but it pops up a screen really quick with the results and then it disappears and then another box appears and the pause is there. I'm wondering if anyone has any tips or tricks on how to get the results of the batch to display, either to screen or text (tried piping but I'm obviously doing it wrong as it doesn't work again when using the runas part), I'd appreciate it.

    Here's the batch:

    SET /p PCASSET=Please type the asset :
    RUNAS /U:DOMAIN\USERNAME_ADMIN "REG QUERY \\%PCASSET%\HKEY_LOCAL_MACHINE\SOFTWARE\DES\CustomData /s"
    ECHO.
    PAUSE

    Its driving me batty! Something that I thought would be so simple has proven more tricky than I thought.

    Thanks in advance.
     
  2. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    Welcome to TSG!

    Code:
    RUNAS [plain]/U:DO[/plain]MAIN\USERNAME_ADMIN "[COLOR=Red][B]cmd /K[/B][/COLOR] REG QUERY \\%PCASSET%\HKLM\SOFTWARE\DES\CustomData /s"
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - batch file runas
  1. niedernsill
    Replies:
    3
    Views:
    424
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/913673

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice