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.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.