public PGView() { InitializeComponent(); if (DesignerProperties.IsInDesignTool) { return; } StartupMode mode = PhoneApplicationService.Current.StartupMode; Debug.WriteLine("StartupMode mode =" + mode.ToString()); if (mode == StartupMode.Activate) { PhoneApplicationService service = PhoneApplicationService.Current; service.Activated += new EventHandler <Microsoft.Phone.Shell.ActivatedEventArgs>(AppActivated); service.Launching += new EventHandler <LaunchingEventArgs>(AppLaunching); service.Deactivated += new EventHandler <DeactivatedEventArgs>(AppDeactivated); service.Closing += new EventHandler <ClosingEventArgs>(AppClosing); } else { } // initializes native execution logic this.nativeExecution = new NativeExecution(ref this.GapBrowser); }
/// <summary> /// 判断app是否以管理员权限运行,不是的话提升权限重启app /// </summary> /// <param name="startupMode"></param> public static void ElvateApp(StartupMode startupMode) { if (!IsElvated()) { // It is not possible to launch a ClickOnce app as administrator directly, // so instead we launch the app as administrator in a new process. var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase); // The following properties run the new process as administrator processInfo.UseShellExecute = true; processInfo.Verb = "runas"; processInfo.Arguments = startupMode.ToString(); // Start the new process try { Process.Start(processInfo); } catch (Exception ex) { } // Shut down the current process Environment.Exit(0); } }
/// <summary> /// 以高权限执行某些任务 /// </summary> /// <param name="startupMode"></param> public static void RunElvatedTask(StartupMode startupMode) { // It is not possible to launch a ClickOnce app as administrator directly, // so instead we launch the app as administrator in a new process. var processInfo = new ProcessStartInfo(Process.GetCurrentProcess().MainModule.FileName); // The following properties run the new process as administrator processInfo.UseShellExecute = true; processInfo.Verb = "runas"; processInfo.Arguments = startupMode.ToString(); // Start the new process try { Process.Start(processInfo); } catch { } }
private string GetActionDescription() { #if (DEBUG) return(ConfigurationState + "\r\n" + GetXMLAction()); #endif switch (ServiceAction) { case Actions.ChangeStartingMode: return("Change the Starting mode of : " + txtBxServiceName.Text); case Actions.Start: return("Start service : " + txtBxServiceName.Text); case Actions.Stop: return("Stop service : " + txtBxServiceName.Text); case Actions.Register: return("Register service : " + txtBxServiceName.Text + " from EXE : " + txtBxPathToEXE.Text + " with Starting Mode : " + StartupMode.ToString()); case Actions.Unregister: return("Unregister service : " + txtBxServiceName.Text); default: return(Description); } }
public void SetStartUpMode(string lightid, StartupMode startup) { var caller = new ApiCaller(); caller.HttpPut("lights/" + lightid, "{\"config\":{\"startup\":{\"mode\":\"" + startup.ToString().ToLower() + "\"}}}"); }