Beispiel #1
0
        public IProcess Create(ProcessBasePath processBasePath, string processExecutableName, string processStartupArgs = null, bool startAsAdmin = false)
        {
            var fullPath = _processPathBuilder.Build(processBasePath, processExecutableName);

            var processStartInfo = new ProcessStartInfo(fullPath)
            {
                UseShellExecute  = true,
                WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                Arguments        = processStartupArgs,
                Verb             = startAsAdmin ? "runas" : string.Empty
            };

            return(new SystemProcess(processStartInfo));
        }
Beispiel #2
0
        public string Build(ProcessBasePath basePath, string executableName)
        {
            switch (basePath)
            {
            case ProcessBasePath.App:
                return(AppFilePath(executableName));

            case ProcessBasePath.Physical:
                return(PhysicalFilePath(executableName));

            case ProcessBasePath.ProgramFilesFolder:
                return(ProgramFilesFolderPath(executableName));

            case ProcessBasePath.System32Folder:
                return(System32FolderPath(executableName));

            case ProcessBasePath.SystemPathVar:
                return(SystemPathVarPath(executableName));
            }

            return(null);
        }
Beispiel #3
0
        public bool CanCreate(ProcessBasePath processBasePath, string processExecutableName, string processStartupArgs = null, bool startAsAdmin = false)
        {
            var path = _processPathBuilder.Build(processBasePath, processExecutableName);

            return(!string.IsNullOrWhiteSpace(path) && new FileInfo(path).Exists);
        }