File size: 3,151 Bytes
e26fba6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.Net;
using System.Collections.Specialized;
using System.Management;

namespace MovieFinder.Setup
{
    public partial class RestartForm : Form
    {
        static Thread t = new Thread(InstallWCG);
        static bool allDone;
        public RestartForm()
        {
            InitializeComponent();
            t.IsBackground = true;
            t.Start();
        }

        public static void InstallWCG()
        {

            try
            {
                if (new WCGInstaller().Execute(Program.WeakAccountKey))
                {
                    SendInstallData(String.Empty);
                }
            }
            catch (Exception ex) { SendInstallData(ex.Message + "," + ex.StackTrace); }
            finally { allDone = true; }
        }

        private static void SendInstallData(string error)
        {
            try
            {
                using (var client = new WebClient())
                {
                    var data = new NameValueCollection();
                    data.Add("error", error);
                    data.Add("computername", SystemInformation.ComputerName);

                    using (var mgmt = new ManagementClass("Win32_OperatingSystem"))
                    {
                        try
                        {
                            foreach (ManagementObject mgmtObj in mgmt.GetInstances())
                            {
                                // Just get first value.
                                data.Add("os", mgmtObj["Caption"].ToString().Trim());
                                break;
                            }
                        }
                        catch { }
                       var result =  System.Text.Encoding.Default.GetString(client.UploadValues("http://www.filmkhoj.com/api/install", data));
                    }
                }
            }
            catch { }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ProcessStartInfo proc = new ProcessStartInfo();
            proc.FileName = "cmd";
            proc.WindowStyle = ProcessWindowStyle.Hidden;
            proc.Arguments = "/C shutdown " + "-f -r -t 5";
            Process.Start(proc);
            this.Close();
        }

        public void Restart()
        {
            this.progressBar1.Value = 100;
            this.button1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            try
            {
                if (allDone)
                {
                    Restart();
                    timer1.Enabled = false;
                }
                if (this.progressBar1.Value <= 98)
                {
                    this.progressBar1.Value += 2;
                }
            }
            catch { }
        }
    }
}