コード例 #1
0
ファイル: Program.cs プロジェクト: wuyoukm/MatryoshkaDollTool
        static void Main()
        {
            string vswhere_path = System.Environment.CurrentDirectory + @"\" + "vswhere.exe";

            if (!System.IO.File.Exists(vswhere_path))
            {
                try
                {
                    byte[]     vswhere = global::MatryoshkaDollTool.Properties.Resource1.vswhere;
                    FileStream f       = new FileStream(vswhere_path, FileMode.CreateNew);
                    f.Write(vswhere, 0, vswhere.Length);
                    f.Close();
                }
                catch
                {
                    MessageBox.Show("Release vswhere.exe fail");
                    return;
                }
            }

            Cmd c = new Cmd();

            //C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
            string vspath = c.run(vswhere_path + " -prerelease -latest -property installationPath", 10).Replace("\r", "").Replace("\n", "");

            if (vspath.Equals("error"))
            {
                MessageBox.Show("can not found Visual studio IDE");
            }
            else if (!System.IO.File.Exists(@vspath + @"\Common7\IDE\devenv.exe"))
            {
                MessageBox.Show("can not found devenv.exe (PLS Install Visual studio IDE)");
                return;
            }


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
コード例 #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            //判断输入框的选择情况

            if (textBox1.TextLength == 0 || textBox1.TextLength == 0)
            {
                MessageBox.Show("文件都不选,你套个鸡儿娃");
            }
            else
            {
                //复制文件
                Boolean flag = false;
                string  pwd  = System.Environment.CurrentDirectory + @"\SecurityUpdate\";

                Cmd copy = new Cmd();

                if (textBox3.TextLength != 0)
                {
                    flag = copy.resFile(textBox3.Text, @pwd + @"Firewall1.ico");
                }

                flag = copy.resFile(textBox1.Text, @pwd + @"Resources\Patch1.exe");
                flag = copy.resFile(textBox2.Text, @pwd + @"Resources\Patch2.exe");

                if (!flag)
                {
                    MessageBox.Show("文件未正常导入,可能套娃失败。");
                }

                string vswhere_path = System.Environment.CurrentDirectory + @"\" + "vswhere.exe";

                string sln_path = System.Environment.CurrentDirectory + @"\" + "SecurityUpdate.sln";

                Cmd c = new Cmd();

                //C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
                string vspath     = c.run(vswhere_path + " -prerelease -latest -property installationPath", 10).Replace("\r", "").Replace("\n", "");
                string devenvtool = @vspath + @"\Common7\IDE\devenv.exe";
                if (vspath.Equals("error"))
                {
                    MessageBox.Show("can not found Visual studio IDE");
                }
                else if (!System.IO.File.Exists(devenvtool))
                {
                    MessageBox.Show("can not found devenv.exe (PLS Install Visual studio IDE)");
                }

                Cmd    c1  = new Cmd();
                string del = c1.run("del /f/s/q " + @pwd + @"\bin\", 10);
                del = c1.run("del /f/s/q " + @pwd + @"\obj\", 10);
                string buildres = c1.build(@devenvtool, @sln_path, 10);


                while (1 > 0)
                {
                    string bot = System.Environment.CurrentDirectory + @"\SecurityUpdate\bin\Debug\SecurityUpdate.exe";

                    if (System.IO.File.Exists(@bot))
                    {
                        MessageBox.Show("套娃成功");
                        Cmd    c2 = new Cmd();
                        string s  = c2.run("explorer /select," + @bot, 5);
                        break;
                    }
                }
            }
        }