コード例 #1
0
ファイル: Integration.cs プロジェクト: isaveu/SmartImage
        internal static void Uninstall()
        {
            // autonomous uninstall routine

            // self destruct

            string exeFileName = RuntimeInfo.ExeLocation;

            const string DEL_BAT_NAME = "SmartImage_Delete.bat";

            string[] commands =
            {
                "@echo off",

                /* Wait approximately 4 seconds (so that the process is already terminated) */
                "ping 127.0.0.1 > nul",

                /* Delete executable */
                $"echo y | del /F {exeFileName}",

                /* Delete this bat file */
                $"echo y | del {DEL_BAT_NAME}"
            };


            var bf = new BatchFileCommand(commands, DEL_BAT_NAME);

            // Runs in background
            bf.Start();
        }
コード例 #2
0
        public static void Update()
        {
            var ui = CheckForUpdates();


            if (ui.Status == VersionStatus.Available)
            {
                var dest = Path.Combine(RuntimeInfo.AppFolder, "SmartImage-new.exe");

                var wc = new WebClient();
                wc.DownloadFile(ui.Latest.AssetUrl, dest);

                string       exeFileName = RuntimeInfo.ExeLocation;
                const string UPDATE_BAT  = "SmartImage_Updater.bat";

                string[] commands =
                {
                    "@echo off",

                    /* Wait approximately 4 seconds (so that the process is already terminated) */
                    "ping 127.0.0.1 > nul",

                    /* Delete executable */
                    "echo y | del /F " + exeFileName,

                    /* Rename */
                    $"move /Y \"{dest}\" \"{exeFileName}\" > NUL",

                    /* Delete this bat file */
                    "echo y | del " + UPDATE_BAT
                };

                var bf = new BatchFileCommand(commands, UPDATE_BAT);

                // Runs in background
                bf.Start();
            }
        }
コード例 #3
0
ファイル: Integration.cs プロジェクト: isaveu/SmartImage
        internal static void HandleContextMenu(IntegrationOption option)
        {
            switch (option)
            {
            case IntegrationOption.Add:
                string fullPath = RuntimeInfo.ExeLocation;

                // Add command and icon to command
                string[] addCode =
                {
                    "@echo off",
                    $"reg.exe add {REG_SHELL_CMD} /ve /d \"{fullPath} \"\"%%1\"\"\" /f >nul",
                    $"reg.exe add {REG_SHELL} /v Icon /d \"{fullPath}\" /f >nul"
                };


                BatchFileCommand.CreateAndRun(addCode, true);

                break;

            case IntegrationOption.Remove:

                string[] removeCode =
                {
                    "@echo off",
                    $@"reg.exe delete {REG_SHELL} /f >nul"
                };


                BatchFileCommand.CreateAndRun(removeCode, true);

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(option), option, null);
            }
        }