Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Windows;
- using System.Windows.Input;
- using System.Diagnostics;
- namespace WpfApp1
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- string start;
- string stop;
- public MainWindow()
- {
- InitializeComponent();
- }
- private void bStart_Click(object sender, RoutedEventArgs e)
- {
- stop = "/C sc queryex wuauserv && sc queryex BITS && sc config wuauserv start= auto && sc start wuauserv && sc config BITS start= auto && sc start BITS";
- ProcessStartInfo p = new ProcessStartInfo("CMD.exe", stop);
- p.UseShellExecute = false;
- p.RedirectStandardOutput = true;
- p.CreateNoWindow = true;
- var proc = Process.Start(p);
- }
- private void bStop_Click(object sender, RoutedEventArgs e)
- {
- string cmd;
- cmd = "/C sc queryex wuauserv";
- ProcessStartInfo p = new ProcessStartInfo("CMD.exe", cmd);
- p.UseShellExecute = false;
- p.RedirectStandardOutput = true;
- p.CreateNoWindow = true;
- var proc = Process.Start(p);
- string cmdoutput = proc.StandardOutput.ReadToEnd();
- cmdoutput = cmdoutput.Replace("\r\n", "").Replace(" ", "");
- int pFrom = cmdoutput.IndexOf("PID:") + "PID:".Length;
- int pTo = cmdoutput.LastIndexOf("FLAGS");
- String result = cmdoutput.Substring(pFrom, pTo - pFrom);
- string res = "taskkill /pid " + result + " /f";
- stop = "/C sc queryex wuauserv && sc queryex BITS && sc config wuauserv start= disabled && sc stop wuauserv && sc config BITS start= disabled && sc stop BITS && " + res;
- tbb.Text = stop;
- System.Diagnostics.Process.Start("CMD.exe", stop);
- //start = "/C sc stop wuauserv";
- //System.Diagnostics.Process.Start("CMD.exe", start);
- }
- private void tbb_MouseEnter(object sender, MouseEventArgs e)
- {
- string cmd1;
- cmd1 = "/C sc queryex wuauserv";
- ProcessStartInfo p1 = new ProcessStartInfo("CMD.exe", cmd1);
- p1.UseShellExecute = false;
- p1.RedirectStandardOutput = true;
- p1.CreateNoWindow = true;
- var proc1 = Process.Start(p1);
- string cmdoutput = proc1.StandardOutput.ReadToEnd();
- cmdoutput = cmdoutput.Replace(" ", "");
- int pFrom = cmdoutput.IndexOf("PID:") + "PID:".Length;
- int pTo = cmdoutput.LastIndexOf("FLAGS");
- String result = cmdoutput.Substring(pFrom, pTo - pFrom);
- /*
- string qbits;
- qbits = "/C sc query wuauserv";
- ProcessStartInfo p2 = new ProcessStartInfo("CMD.exe", qbits);
- p2.UseShellExecute = false;
- p2.RedirectStandardOutput = true;
- p2.CreateNoWindow = true;
- var proc2 = Process.Start(p2);
- string s2 = proc2.StandardOutput.ReadToEnd();
- if (s1.Contains("STOPPED") && s2.Contains("STOPPED"))
- tbb.Text = "STOPPED";
- if (s2.Contains("RUNNING") && s2.Contains("RUNNING"))
- tbb.Text = "RUNNING";
- */
- tbb.Text = result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement