public static void ShowProperties(string fileName) { ShellExecuteInfo info = new ShellExecuteInfo { cbSize = ShellExecuteInfo.SizeOf, lpFile = fileName, nShow = ShowWindowType.Show, fMask = Win32.SeeMaskInvokeIdList, lpVerb = "properties" }; Win32.ShellExecuteEx(ref info); }
public static void StartProgramAdmin(string program, string args, MethodInvoker successAction, ShowWindowType showType, IntPtr hWnd) { ShellExecuteInfo info = new ShellExecuteInfo { cbSize = ShellExecuteInfo.SizeOf, lpFile = program, nShow = showType, lpVerb = "runas", lpParameters = args, hWnd = hWnd }; if (Win32.ShellExecuteEx(ref info)) { if (successAction != null) successAction(); } }
public static WaitResult StartProcessHackerAdminWait(string args, MethodInvoker successAction, IntPtr hWnd, uint timeout) { ShellExecuteInfo info = new ShellExecuteInfo { cbSize = ShellExecuteInfo.SizeOf, lpFile = ProcessHandle.Current.MainModule.FileName, nShow = ShowWindowType.Show, fMask = 0x40, // SEE_MASK_NOCLOSEPROCESS lpVerb = "runas", lpParameters = args, hWnd = hWnd }; if (Win32.ShellExecuteEx(ref info)) { if (successAction != null) successAction(); WaitResult result = Win32.WaitForSingleObject(info.hProcess, timeout); Win32.NtClose(info.hProcess); return result; } // An error occured - the user probably canceled the elevation dialog. return WaitResult.Abandoned; }
public static void StartProgramAdmin(string program, string args, MethodInvoker successAction, ShowWindowType showType, IntPtr hWnd) { var info = new ShellExecuteInfo(); info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info); info.lpFile = program; info.nShow = showType; info.lpVerb = "runas"; info.lpParameters = args; info.hWnd = hWnd; if (Win32.ShellExecuteEx(ref info)) { if (successAction != null) successAction(); } }
public static WaitResult StartProcessHackerAdminWait(string args, MethodInvoker successAction, IntPtr hWnd, uint timeout) { var info = new ShellExecuteInfo(); info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf(info); info.lpFile = ProcessHandle.GetCurrent().GetMainModule().FileName; info.nShow = ShowWindowType.Show; info.fMask = 0x40; info.lpVerb = "runas"; info.lpParameters = args; info.hWnd = hWnd; if (Win32.ShellExecuteEx(ref info)) { if (successAction != null) successAction(); var result = Win32.WaitForSingleObject(info.hProcess, timeout); Win32.CloseHandle(info.hProcess); return result; } else { return WaitResult.Abandoned; } }
public static void ShowProperties(string fileName) { var info = new ShellExecuteInfo(); info.cbSize = Marshal.SizeOf(info); info.lpFile = fileName; info.nShow = ShowWindowType.Show; info.fMask = Win32.SeeMaskInvokeIdList; info.lpVerb = "properties"; Win32.ShellExecuteEx(ref info); }