Have you ever needed to run a command as a different user? Perhaps they should run a command in a user context they normally cannot? Usually used for quick fixes you could create a simple script using some vb-script and expose the password or use a runas command in a batch file? But you don’t want the user to have the password, right? Well the answer is a quick utility I coded up using .net 2.0:
Userexec.exe is a command line program that basically works just as runas except: it can accept passwords on the command line, and it can accept a encrypted command line. The encryption is a basic quick one but should keep average Joe from getting your password. This is NOT a best practice and probably there is a better way of solving the problem.. but anyways find it attached to my post.
UserExec by Daniel Sörlöv, daniel@sorlov.com, all rights reserved 2010.
USEREXEC USAGE:
USEREXEC /u:<username> /p:<password> /c:<command>
[ /l | /h | /m | /x | /a:<arguments> ]
USEREXEC /e:<string-to-encrypt>
/l Causes the users profile to be loaded
/h Hides the requested application
/m Runs the command minimized
/s Specifies the path on which to start
/x Use encrypted command line
Examples:
> userexec /l /u:mydomain\administrator /p:mypass /c:”cmd.exe”
> userexec /e:<string to encrypt>
> userexec /h /u:mydomain\administrator /p:mypass /c:”cmd.exe” /a:”/c auto.bat”
Use it if you need it, send me reports if something fails and perhaps I will fix it. The tools is without guarantee and without support but could be quite usefull. Download here