Use Runas in a Batch Script

Runas does not accept a password on the command line, nor can you pipe it to it on STDIN. It requires keyboard input.
However, to make life easier, there’s a Visual Basic Script available that will allow you to use Runas from the command line and supply a password to it. It is created by Jefferey Hicks (MS MVP Powershell) and is called VBRunas.

cscript //nologo runas.vbs <Username> <Password> <Command>

You can download the script from my server, or from Jeffery’s website.

Published by

Rich

Just another IT guy.

Leave a Reply

Your email address will not be published. Required fields are marked *