Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows;
  5. using System.Windows.Input;
  6. using System.Diagnostics;
  7.  
  8. namespace WpfApp1
  9. {
  10. /// <summary>
  11. /// Interaction logic for MainWindow.xaml
  12. /// </summary>
  13. public partial class MainWindow : Window
  14. {
  15. string start;
  16. string stop;
  17.  
  18. public MainWindow()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void bStart_Click(object sender, RoutedEventArgs e)
  24. {
  25. stop = "/C sc queryex wuauserv && sc queryex BITS && sc config wuauserv start= auto && sc start wuauserv && sc config BITS start= auto && sc start BITS";
  26. ProcessStartInfo p = new ProcessStartInfo("CMD.exe", stop);
  27. p.UseShellExecute = false;
  28. p.RedirectStandardOutput = true;
  29. p.CreateNoWindow = true;
  30. var proc = Process.Start(p);
  31. }
  32.  
  33. private void bStop_Click(object sender, RoutedEventArgs e)
  34. {
  35. string cmd;
  36. cmd = "/C sc queryex wuauserv";
  37. ProcessStartInfo p = new ProcessStartInfo("CMD.exe", cmd);
  38. p.UseShellExecute = false;
  39. p.RedirectStandardOutput = true;
  40. p.CreateNoWindow = true;
  41. var proc = Process.Start(p);
  42.  
  43. string cmdoutput = proc.StandardOutput.ReadToEnd();
  44. cmdoutput = cmdoutput.Replace("\r\n", "").Replace(" ", "");
  45. int pFrom = cmdoutput.IndexOf("PID:") + "PID:".Length;
  46. int pTo = cmdoutput.LastIndexOf("FLAGS");
  47. String result = cmdoutput.Substring(pFrom, pTo - pFrom);
  48. string res = "taskkill /pid " + result + " /f";
  49.  
  50.  
  51. 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;
  52. tbb.Text = stop;
  53. System.Diagnostics.Process.Start("CMD.exe", stop);
  54. //start = "/C sc stop wuauserv";
  55. //System.Diagnostics.Process.Start("CMD.exe", start);
  56. }
  57.  
  58. private void tbb_MouseEnter(object sender, MouseEventArgs e)
  59. {
  60.  
  61.  
  62. string cmd1;
  63. cmd1 = "/C sc queryex wuauserv";
  64. ProcessStartInfo p1 = new ProcessStartInfo("CMD.exe", cmd1);
  65. p1.UseShellExecute = false;
  66. p1.RedirectStandardOutput = true;
  67. p1.CreateNoWindow = true;
  68. var proc1 = Process.Start(p1);
  69.  
  70. string cmdoutput = proc1.StandardOutput.ReadToEnd();
  71. cmdoutput = cmdoutput.Replace(" ", "");
  72. int pFrom = cmdoutput.IndexOf("PID:") + "PID:".Length;
  73. int pTo = cmdoutput.LastIndexOf("FLAGS");
  74. String result = cmdoutput.Substring(pFrom, pTo - pFrom);
  75. /*
  76. string qbits;
  77. qbits = "/C sc query wuauserv";
  78. ProcessStartInfo p2 = new ProcessStartInfo("CMD.exe", qbits);
  79. p2.UseShellExecute = false;
  80. p2.RedirectStandardOutput = true;
  81. p2.CreateNoWindow = true;
  82. var proc2 = Process.Start(p2);
  83. string s2 = proc2.StandardOutput.ReadToEnd();
  84.  
  85. if (s1.Contains("STOPPED") && s2.Contains("STOPPED"))
  86. tbb.Text = "STOPPED";
  87. if (s2.Contains("RUNNING") && s2.Contains("RUNNING"))
  88. tbb.Text = "RUNNING";
  89.  
  90. */
  91. tbb.Text = result;
  92.  
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement