Esempio n. 1
0
        static void Main(string[] args)
        {
            NSudoInstance instance = new NSudoInstance();

            instance.WriteLog("M2.NSudo.Demo", "Start");

            try
            {
                instance.CreateProcess(
                    NSUDO_USER_MODE_TYPE.TRUSTED_INSTALLER,
                    NSUDO_PRIVILEGES_MODE_TYPE.ENABLE_ALL_PRIVILEGES,
                    NSUDO_MANDATORY_LABEL_TYPE.SYSTEM,
                    NSUDO_PROCESS_PRIORITY_CLASS_TYPE.NORMAL,
                    NSUDO_SHOW_WINDOW_MODE_TYPE.DEFAULT,
                    0,
                    true,
                    "cmd",
                    null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(
                    "CreateProcess Failed, return {0}",
                    ex.HResult);
            }

            instance.WriteLog("M2.NSudo.Demo", "End");

            Console.WriteLine(instance.ReadLog());

            Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            NSudoInstance instance = new NSudoInstance();

            instance.CreateProcess(
                NSUDO_USER_MODE_TYPE.TRUSTED_INSTALLER,
                NSUDO_PRIVILEGES_MODE_TYPE.ENABLE_ALL_PRIVILEGES,
                NSUDO_MANDATORY_LABEL_TYPE.SYSTEM,
                NSUDO_PROCESS_PRIORITY_CLASS_TYPE.NORMAL,
                NSUDO_SHOW_WINDOW_MODE_TYPE.DEFAULT,
                0,
                true,
                "cmd",
                null);

            Console.ReadKey();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            NSudoInstance instance = new NSudoInstance();

            INSudoClient client = instance.CreateClient();

            IntPtr currentProcessToken = client.OpenCurrentProcessToken(0x02000000);

            if (currentProcessToken != null)
            {
                client.AdjustTokenAllPrivileges(currentProcessToken, 0x00000002);
            }

            Console.WriteLine("Hello World!");

            Console.ReadKey();
        }