Sudo for Vista
The following ruby script when given any executable file path as the argument runs it in administrative mode.
1: require 'Win32API'
2:
3: def shell_execute(process_name)
4: process = ''
5: process.replace(process_name)
6: se = Win32API.new("shell32", "ShellExecute", ['P','P','P','P','P','I'], 'I')
7: se.Call(nil,"runas",process,nil,nil,5)
8: end
9:
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.
1 Comment to Sudo for Vista
Leave a comment
Blogroll
Recent Posts
- Autocompleting ssh, rake, cap command parameters using PowerShell
- Using RubyAmf for creating a CRUD application in Rails
- Multiple ways to open PowerShell in the current Explorer window
- Context sensitive auto-completion using PowerShell, PowerTab and GIT
- Displaying GIT Branch on your PowerShell prompt
XBox Live
Songs I like
Categories
- adobe (4)
- amarok (1)
- C# (2)
- chat application (1)
- crud (2)
- cygwin (1)
- explorer (1)
- expression blend (1)
- flex (4)
- FOSS (2)
- free (1)
- GIT (3)
- ID3 (1)
- java (1)
- microsoft (3)
- mxml (2)
- nokia (1)
- open source (5)
- perl (1)
- powerpoint (2)
- powershell (3)
- rails (3)
- right click (1)
- ruby (9)
- ruby on rails (3)
- security (3)
- silverlight (4)
- smart playlist (1)
- socket (1)
- software (7)
- ssh (1)
- sudo (1)
- tabs (1)
- tomcat (1)
- user interface (6)
- vista (9)
- vista, security (2)
- visual studio 2008 (1)
- win32ole (1)
- windows (13)
- windows media player (1)
- wpf (1)
- xaml (4)
- XP (3)

[...] 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 [...]