Search code examples
cmd

Send an (enter) to a runas command without user input


I have a need to perform a runas command, and send an enter keypress to the command without user interaction.

I understand that piping results out to a file, but i want to do it the other way, send n enter keypress to the command.

This is the command

runas.exe /user:XXX\USER_LOGIN notepad.exe

When this command is run, it prompts for a password... i dont want to supply a password, just press the enter key.

FYI - this is a very simple user refresh, so it doesn't go stale when not used in a while.


Solution

  • Try piping in a blank quoted string:

    echo "" | runas.exe /user:XXX\USER_LOGIN notepad.exe