ExecuteAs utility

by Dmitry Kirsanov 27. October 2011 17:50

Well, yet another useful command line utility. This one is for system administrators in need to run some command on behalf of another user.

Why bother, if there is a command in Windows, called runas? Well, mainly because it doesn’t accept the password as command line parameter, and also because I wanted to add more features to such simple process.

This is the help text you get when running this program without parameters:

Syntax: executeas.exe /u:UserName /p:Password /x:Priority /d:Domain /a:Affinity /quiet /hide /noprofile /wait /t:60 [program name]
Where t is a timeout in seconds to wait for program completion.
The only required parameter is program name. You can place command line arguments after the program name.

As you can understand, UserName is the user name of target user without the domain name,
Password is his password,
Priority is the priority at which you want this program to be executed (1 – idle, 2 – below normal, 3 – normal, 4 – above normal, 5 – high),
Domain is the domain part of the user name, if needed,
Affinity is how many CPU cores you’d like to use,
Quiet won’t produce any output,
Hide will hide the target program, so it will not be displayed to user,
NoProfile means that profile of target user won’t be loaded,
Wait will wait until the target program will be completed – useful when running from batch file.

So, here it is and have fun!

As  always, .net framework is required for this program to run. This time it’s .net 3.5, which is installed by default on Windows 7 and is available as feature on Windows Server 2008.

ExecuteAs.zip (3.99 kb)

blog comments powered by Disqus