Sudo for Vista

Posted on November 28, 2007. Filed under: ruby, security, software, vista |

The following ruby script when given any executable file path as the argument runs it in administrative mode.

   1: require 'Win32API'
   3: def shell_execute(process_name)
   4:     process = ''
   5:     process.replace(process_name)
   6:     se ="shell32", "ShellExecute", ['P','P','P','P','P','I'], 'I')
   7:     se.Call(nil,"runas",process,nil,nil,5)
   8: end
  10: shell_execute(ARGV[0])


In Vista you can do the same by right clicking on the file and selecting “Run as Administrator” but this script allows you to run a process in admin mode using the command line.

The ShellExecute function resides in the shell32.dll and is documented here.

By just giving “runas” as the second parameter to the function the process is executed in the administrative mode.


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

One Response to “Sudo for Vista”

RSS Feed for Blogging on Technology Comments RSS Feed

[…] sudo, vista, vista, security, windows by techblogger on April 2nd, 2008 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 […]

Where's The Comment Form?

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

%d bloggers like this: