private void btnUninstall_Click(object sender, EventArgs e) { /* when detected server stop, start this server */ StartServerAfterServiceStopped = true; WebDAVService.StopService(); new Thread(() => { string executable = Assembly.GetAssembly(typeof(WebDAVServer)).Location; try { ManagedInstallerClass.InstallHelper(new[] { "/u", executable }); } catch (InvalidOperationException ex) { MessageBox.Show("Could not uninstall service. Make sure you run the server as a privileged user (e.g. Administrator).", "Failed to uninstall Windows Service"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }).Start(); }
private void btnWriteConfig_Click(object sender, EventArgs e) { SaveConfig(); if (WebDAVService.Installed && WebDAVService.Running) { StartServiceAfterServiceStopped = true; new Thread(() => { try { WebDAVService.StopService(); } catch (InvalidOperationException ex) { MessageBox.Show("Could not restart service. Make sure you run the server as a privileged user (e.g. Administrator).", "Failed to stop Windows Service"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }).Start(); } }
private void btnStartService_Click(object sender, EventArgs e) { new Thread(() => { try { Server.Stop("Started Windows Service"); WebDAVService.StartService(); } catch (InvalidOperationException ex) { MessageBox.Show("Could not start service. Make sure you run the server as a privileged user (e.g. Administrator).", "Failed to start Windows Service"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }).Start(); }
private void RefreshLog() { lock (txtLog) { if (StartServerAfterServiceStopped && !WebDAVService.Running) { StartServerAfterServiceStopped = false; Server.Restart(); } if (StartServiceAfterServiceStopped && !WebDAVService.Running) { StartServiceAfterServiceStopped = false; WebDAVService.StartService(); } UpdateButtons(); txtLog.Text = Server.Statistics + Environment.NewLine + Server.LogMessages; } }
private void btnStopService_Click(object sender, EventArgs e) { /* when detected server stop, start this server */ StartServerAfterServiceStopped = true; new Thread(() => { try { WebDAVService.StopService(); } catch (InvalidOperationException ex) { MessageBox.Show("Could not stop service. Make sure you run the server as a privileged user (e.g. Administrator).", "Failed to stop Windows Service"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }).Start(); }
static void Main(string[] arg) { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += currentDomain_UnhandledException; //currentDomain.FirstChanceException += currentDomain_FirstChanceException; currentDomain.ProcessExit += currentDomain_ProcessExit; if (Environment.UserInteractive || Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Instance = new WebDAVServerForm(arg); Application.Run(Instance); } else { Service = new WebDAVService(); var ServicesToRun = new ServiceBase[] { Service }; ServiceBase.Run(ServicesToRun); } }
private void btnInstall_Click(object sender, EventArgs e) { new Thread(() => { Server.Stop("Installed Windows Service"); string executable = Assembly.GetAssembly(typeof(WebDAVServer)).Location; try { ManagedInstallerClass.InstallHelper(new[] { "/i", executable }); WebDAVService.StartService(); } catch (InvalidOperationException ex) { MessageBox.Show("Could not install service. Make sure you run the server as a privileged user (e.g. Administrator).", "Failed to install Windows Service"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }).Start(); }