示例#1
0
        static void Main(string[] args)
        {
            string tag_company = "Coreberg";
            int    tag_number  = 200001;

            if (!InstalledSoftware.NameContain("OCS Inventory"))
            {
                OCS.Install(tag_company, tag_number);                                  // Ставим OCS если он не установлен
            }
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\Teamviewer\\")) //проверяем наличие
            {
                Console.WriteLine("в инсталяторе не найден каталог Teamviwer");
                Console.WriteLine();
                //Console.WriteLine(" press any key...");
                //Console.ReadKey();
                return;
            }
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\OCSi\\"))
            {
                Console.WriteLine("в инсталяторе не найден каталог OCSi");
                Console.WriteLine();
                //Console.WriteLine(" press any key...");
                //Console.ReadKey();
                return;
            }
            if (InstalledSoftware.NameContain("Teamviewer"))
            {
                TeamViewer.DisplayInfo();
                TeamViewer.Uninstall();
                //Console.WriteLine(" press any key...");
                //Console.ReadKey();
                Console.WriteLine();
                TeamViewer.Install(tag_company, tag_number);
                TeamViewer.DisplayInfo();
                //Console.WriteLine(" press any key...");
                //Console.ReadKey();
                Console.WriteLine();
            }
            else
            {
                TeamViewer.Install(tag_company, tag_number);

                TeamViewer.DisplayInfo();
                //Console.WriteLine(" press any key...");
                //Console.ReadKey();
                Console.WriteLine();
            }


            DesktopInfo.Install();

            Console.WriteLine(" press any key...");
            Console.ReadKey();
            Console.WriteLine();
        }
示例#2
0
 static public void Uninstall()
 {
     try
     {
         if (InstalledSoftware.NameContain("teamviewer", "msi"))
         {
             Console.WriteLine("Удаляем \"" + InstalledSoftware.GetNameContain("teamviewer", "msi") + "\"");
             Process process = new Process();
             process.StartInfo.WorkingDirectory = TeamViewer.Path; //sets the working directory in which the exe file resides.
             process.StartInfo.FileName         = string.Format(TeamViewer.Path + "\\uninstall.exe");
             process.StartInfo.Arguments        = " /S";
             process.StartInfo.UseShellExecute  = false;
             process.StartInfo.CreateNoWindow   = false;
             Console.WriteLine("Запуск: " + process.StartInfo.FileName + process.StartInfo.Arguments);
             process.Start();
             process.WaitForExit();
             Console.WriteLine("Удаление завершено.");
             Console.WriteLine();
         }
         if (InstalledSoftware.NameContain2("teamviewer", "msi"))
         {
             Console.WriteLine("Удаляем \"" + InstalledSoftware.GetNameContain2("teamviewer", "msi") + "\"");
             Process process = new Process();
             process.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory() + "\\TeamViewer";
             process.StartInfo.FileName         = "msiexec.exe";
             process.StartInfo.Arguments        = " /x \"" + Directory.GetCurrentDirectory() + "\\TeamViewer\\" + TeamViewer.GetMSIPackegeName() + "\" /norestart /qn";
             process.StartInfo.UseShellExecute  = false;
             process.StartInfo.CreateNoWindow   = false;
             Console.WriteLine("Запуск: " + process.StartInfo.FileName + process.StartInfo.Arguments);
             process.Start();
             process.WaitForExit();
             Console.WriteLine("Удаление завершено.");
             Console.WriteLine();
         }
     }
     catch (Exception)
     {
         Console.WriteLine("что-то пошло не так :( и метод Teamviewer.Uninstall() не отработал как положено");
     }
 }