using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GetADoc
{
    internal class RightClickInst
    {
        public static string RunInst()
        {
            string ErrTxt = "";
            try
            {
                // カレントディレクトリを取得
                string currentDirectory = Environment.CurrentDirectory;

                // プロセス情報を設定
                ProcessStartInfo processInfo = new ProcessStartInfo();
                processInfo.FileName = "cmd.exe";
                processInfo.Arguments = $"/c \"{currentDirectory}\\InstAdocUI.js.bat\" /Inst";  // /c:プロセス終了後にcmd.exeを終了
                processInfo.WorkingDirectory = currentDirectory;
                processInfo.CreateNoWindow = false;
                //processInfo.RedirectStandardError = true;
                processInfo.UseShellExecute = true; //false
                processInfo.Verb = "runas";   //管理者権限で実行

                // プロセスを開始
                Process process = new Process();
                process.StartInfo = processInfo;

                process.Start();

                //ErrTxt = process.StandardError.ReadToEnd();

                // プロセスの終了を待機
                process.WaitForExit();
            }catch(Exception ex)
            {

                ErrTxt = ex.Message;
            }
            return ErrTxt;
        }


    }
}
