Share

su for windows, run programs in elevated mode..

Dysfunktion CR3W

Hye guys, just wanna share a simple code here. Its su for windows, just like the UNIX's su, to run any program in elevated mode. I created this to quickly run my tools under elevated mode.

 Here's the C# code. Just run it as usual,   su yourprogram parameters Have fun!!

 using System;
 using System.Collections.Generic;
 using System.Text;

 namespace su
 {
     class Program
     {
         public enum ShowCommands : int
         {
             SW_HIDE = 0,
             SW_SHOWNORMAL = 1,
             SW_NORMAL = 1,
             SW_SHOWMINIMIZED = 2,
             SW_SHOWMAXIMIZED = 3,
             SW_MAXIMIZE = 3,
             SW_SHOWNOACTIVATE = 4,
             SW_SHOW = 5,
             SW_MINIMIZE = 6,
             SW_SHOWMINNOACTIVE = 7,
             SW_SHOWNA = 8,
             SW_RESTORE = 9,
             SW_SHOWDEFAULT = 10,
             SW_FORCEMINIMIZE = 11,
             SW_MAX = 11
         }

         [System.Runtime.InteropServices.DllImport("shell32.dll")]
         static extern IntPtr ShellExecute(
             IntPtr hwnd,
             string lpOperation,
             string lpFile,
             string lpParameters,
             string lpDirectory,
             ShowCommands nShowCmd);

         static void Main(string[] args)
         {
             if (args.Length == 0) return;
             string param = "";
             for (int i = 1; i < args.Length; i++) param += args[i] + " ";
             ShellExecute(IntPtr.Zero, "runas", args[0], param, "", ShowCommands.SW_SHOWNORMAL);
         }
     }
 }

 Tag: runas elevated administrator mode su c#

Trackback

Trackback URL for this entry: http://blog.yusri.com.my/v2/trackback.php/windows-su

No trackback comments for this entry.

0 comments

# /boot/menu.conf

# /main/
 /home
 /mylife
 /DysfunktionCR3W
 /spaceXploration
 /life, engineered

# /interact/

 /my wishlist!
 /my travel map
 /mediagallery
 /my toolbox
 /syok shout/

# /stuff/

 /hmsecurity
 /n3wb0rn
 /slashdot
 /the broken
 /distrowatch
 /quantum computing
 /kernel

Shout Out~!

My Account





Sign up as a New User
Lost your password?


# /home/yusri/favlink

Slackware Linux
The linux distro i love!



SMK Sultan Badlishah

# /boot/boot.conf




Umbrella Corporation

# /etc/lic

License

Creative Commons License

WTFPL

Waktu Solat

#/adv


tweetshyt!