New and Improved Sudo for Vista (now remembers credentials)

Posted on April 2, 2008. Filed under: security, sudo, vista, vista, security, windows |

In one of my earlier blog post I shared source code for a simple utility that I had made. It could be used to launch elevated processes from the command line.

So opening a Elevated command prompt was as simple as writing

sudo cmd

Actually the code for this is very simple as it just executes a well documented system function ShellExecute.

I have made some changes to the script and now it remembers the credentials. So once you execute any command, Vista will ask you confirmation only once and any subsequent call won’t ask for the confirmation with the UAC dialog box.

The concept behind this is very simple too:

A process launched from any elevated process will be (by default) automatically elevated at administrative assess. So what this script (client) does is launch a elevated Ruby server first time you run it, so it will Vista will prompt you for confirmation. For any subsequent call it will just see that the server is already running and it will just use that server for elevating launched processes.


How it works:

When you write “sudo cmd” in the command prompt (or run it any where else):

  • Check if the “sudo server” process is running. If not then start it. (This will result in a UAC prompt).
  • Connect to the server using TCP and ask it to run the command “sudo cmd”.
  • The server will launch the elevated process.


The code for Client and the Server is in Ruby and thus can easily be improved upon. One can easily add code to kill the server after a specific time interval or after running a fixed number of commands. Actually I am not sure if this is the correct way to handle this, so any comments will be welcome.

 Download Here

Just un-rar this file anywhere and add it to system path. To run it just write sudo <command name> in “command prompt” of in the “Run dialog box”. Example to run notepad: “sudo notepad”

This code was written with ruby 1.8.6.

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: