Beispiel #1
0
        private void OnShowDependencies(object sender, RoutedEventArgs e)
        {
            string dependencyViewer;

            if (ProcessInfoTools.FindExecutable("depends.exe", out dependencyViewer))
            {
                string filename;
                if (GetSelectedFileName(out filename))
                {
                    Process.Start(dependencyViewer, string.Format("\"{0}\"", filename));
                }
            }
            else
            {
                MessageBox.Show("Unable to find DEPENDS.EXE", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #2
0
Datei: su.cs Projekt: jwg4/gtools
        /// <summary>
        /// This program finds an executable on the PATH. It can also find other stuff on the path, but
        /// mostly it finds the executable.s
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);

            Args = new InputArgs("su", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Parameter, "cmd", "cmd.exe", Presence.Optional, resource.IDS_DOC_cmd_param);

            if (Args.Process(args))
            {
                string command = Args.GetString("cmd");
                if (command.Equals("cmd.exe", StringComparison.OrdinalIgnoreCase))
                {
                    if (!IsAdministrator())
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(Environment.SystemDirectory, "cmd.exe"));
                        startInfo.Verb             = "runas";
                        startInfo.WorkingDirectory = Environment.CurrentDirectory;
                        startInfo.Arguments        = string.Format("/K \"cd /d {0}\"", startInfo.WorkingDirectory);

                        System.Diagnostics.Process.Start(startInfo);
                    }
                    else
                    {
                        Console.WriteLine(resource.IDS_ERR_AlreadyRunningAsAdministrator);
                    }
                }
                else
                {
                    string exe;
                    if (ProcessInfoTools.FindExecutable(command, out exe))
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo(exe);
                        startInfo.Verb             = "runas";
                        startInfo.WorkingDirectory = Environment.CurrentDirectory;

                        System.Diagnostics.Process.Start(startInfo);
                    }
                    else
                    {
                        Console.WriteLine(resource.IDS_ERR_UnableToFindFile, command);
                    }
                }
            }
        }