Esempio n. 1
0
        private ComponentTask SetRegistry_ScheduleWindowsTempFolderFoldersCleanup()
        {
            bool runOnce = true;

            RegistryUtil.StartupRegistryHives startupRegistryHive = RegistryUtil.StartupRegistryHives.LOCAL_MACHINE;
            string registryKeyValueName = "TBInstallerCleanup_WindowsTempFolderFolders";

            CMDForLoopCommand command = new CMDForLoopCommand();

            command.ForSwitch     = new CommandOption("/", "d");
            command.LoopParameter = "%x";
            command.InParameter   = StringUtil.DQuote(@"C:\Windows\Temp\*");

            CLICommand loopedCommand = new CLICommand();

            loopedCommand.Program = "@rd";
            loopedCommand.Options.Add(new CommandOption("/", "s"));
            loopedCommand.Options.Add(new CommandOption("/", "q"));
            loopedCommand.Options.Add(new CommandOption(StringUtil.DQuote("%x")));

            command.LoopedCommand = loopedCommand;

            StringComparison validationStringComparison = StringComparison.OrdinalIgnoreCase;

            return(ComponentTaskPresets.SetRegistryRunCommand(
                       runOnce,
                       startupRegistryHive,
                       registryKeyValueName,
                       command,
                       validationStringComparison));
        }
Esempio n. 2
0
        public static ComponentTask SetRegistryRunCommand(
            bool runOnce,
            RegistryUtil.StartupRegistryHives startupRegistryHive,
            string registryKeyValueName,
            CMDForLoopCommand command,
            StringComparison validationStringComparison
            )
        {
            /************************************************
            * Task Type: Setup
            * Task Prerequisite: None.
            * Task Description: Create a Run or RunOnce registry key
            *                   at the HKLM or HKCU registry hive for
            *                   a cmd /c command.
            * Task Validation: No cleanup required.
            ************************************************/

            Func <bool> prequisiteFunc = null;

            Action setupAction =
                () => RegistryUtil.SetRunCommand(
                    runOnce,
                    startupRegistryHive,
                    registryKeyValueName,
                    command);

            Func <bool> setupActionValidation =
                () => RegistryUtil.RegistryKeyValueDataExists(
                    RegistryUtil.GetStartupRunKey(runOnce, startupRegistryHive),
                    registryKeyValueName,
                    SystemPathConstants.CmdPathCommand + " " + command.ToString(),
                    validationStringComparison);

            SetupTask setupTask = new SetupTask(prequisiteFunc, setupAction, setupActionValidation, true);

            /************************************************/

            /************************************************
            * Task Type: Cleanup
            * Task Description: No cleanup required.
            ************************************************/
            Action      cleanupAction           = null;
            Func <bool> cleanupActionValidation = null;

            CleanupTask cleanupTask = new CleanupTask(cleanupAction, cleanupActionValidation);

            /************************************************/

            return(new ComponentTask(setupTask, cleanupTask));
        }