MainWindow.xaml.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Controls;
  12. using System.Windows.Data;
  13. using System.Windows.Documents;
  14. using System.Windows.Input;
  15. using System.Windows.Media;
  16. using System.Windows.Media.Imaging;
  17. using System.Windows.Navigation;
  18. using System.Windows.Shapes;
  19. using Path = System.IO.Path;
  20. namespace MediaBrowser.Uninstaller
  21. {
  22. /// <summary>
  23. /// Interaction logic for MainWindow.xaml
  24. /// </summary>
  25. public partial class MainWindow : Window
  26. {
  27. public MainWindow()
  28. {
  29. //All our work is behind the scenes
  30. var args = Environment.GetCommandLineArgs();
  31. var product = args.Length > 1 ? args[1] : "server";
  32. //copy the real program to a temp location so we can delete everything here (including us)
  33. var tempExe = Path.Combine(Path.GetTempPath(), "MBUninstall.exe");
  34. using (var file = File.Create(tempExe, 4096, FileOptions.DeleteOnClose))
  35. {
  36. //copy the real uninstaller to temp location
  37. File.WriteAllBytes(tempExe, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase) ?? "","MediaBrowser.Uninstaller.Execute.exe")));
  38. //kick off the copy
  39. Process.Start(tempExe, product);
  40. //wait for it to start up
  41. Thread.Sleep(500);
  42. //and shut down
  43. Close();
  44. }
  45. //InitializeComponent();
  46. }
  47. }
  48. }