当前位置: 首页>>代码示例>>C#>>正文


C# Diagnostics.ProcessStartInfo类代码示例

本文整理汇总了C#中System.Diagnostics.ProcessStartInfo的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.ProcessStartInfo类的具体用法?C# System.Diagnostics.ProcessStartInfo怎么用?C# System.Diagnostics.ProcessStartInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Diagnostics.ProcessStartInfo类属于命名空间,在下文中一共展示了System.Diagnostics.ProcessStartInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyFolder

        //-------------------------------------------------------------------//
        //add
        public void CopyFolder(DirectoryInfo source, DirectoryInfo target)
        {
            try
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                startInfo.FileName = "cmd.exe";
                if (!(Directory.Exists(target.FullName)))
                {
                    startInfo.Arguments = "/C md " + target.FullName;
                    process.StartInfo = startInfo;
                    process.Start();
                    process.WaitForExit();

                }
                string cmd = "/c xcopy ";
                startInfo.Arguments = cmd + source.FullName + " " + target.FullName + " /e /y";
                process.StartInfo = startInfo;
                process.Start();
                process.WaitForExit();
            }
            catch (Exception e)
            {
                string[] temp = e.ToString().Split('\'');
                string ex = temp[0] + "\n" + temp[1];
                temp = ex.Split(new string[] { ": " }, StringSplitOptions.None);
                MessageBox.Show("" + temp[1]);
            }
        }
开发者ID:Saladin2020,项目名称:CompareSystem,代码行数:32,代码来源:fileManage.cs

示例2: bSaveAndStart_Click

 private void bSaveAndStart_Click(object sender, EventArgs e)
 {
     WriteConfig();
     System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("GPSTrackingServer.exe");
     System.Diagnostics.Process.Start(psi);
     Environment.Exit(0);
 }
开发者ID:vlinhd11,项目名称:GPSTracker,代码行数:7,代码来源:Settings.cs

示例3: CatchImg

        /// <summary>
        /// 截取视频缩略图
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="imgFile"></param>
        /// <returns></returns>
        public static bool CatchImg(string fileName, string imgFile)
        {
            const string ffmpeg = "ffmpeg.exe";
            //string flvImg = imgFile + ".jpg";
            string flvImgSize = "640*480";
            MediaPlayerFactory m_factory = new MediaPlayerFactory();
            IVideoPlayer m_player = m_factory.CreatePlayer<IVideoPlayer>();
            IMediaFromFile m_media = m_factory.CreateMedia<IMediaFromFile>(fileName);
            m_player.Open(m_media);
            m_media.Parse(true);

            System.Drawing.Size size = m_player.GetVideoSize(0);
            if (!size.IsEmpty)
                flvImgSize = size.Width.ToString() + "*" + size.Height.ToString();
            //m_player.TakeSnapShot(1, @"C:");
            System.Diagnostics.ProcessStartInfo ImgstartInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
            ImgstartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            ImgstartInfo.Arguments = "   -i   " + fileName + "  -y  -f  image2   -ss 2 -vframes 1  -s   " + flvImgSize +
                                     "   " + imgFile;
            try
            {
                System.Diagnostics.Process.Start(ImgstartInfo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
            return true;
        }
开发者ID:jasine,项目名称:KinectExplorer,代码行数:36,代码来源:VideoUnity.cs

示例4: OpenInternetBrowser

        public static bool OpenInternetBrowser(string url)
        {
#if XB1
			return true;
#else
			try
            {
                try
                {
                    System.Diagnostics.Process.Start(url);
                }
                // System.ComponentModel.Win32Exception is a known exception that occurs when Firefox is default browser.  
                // It actually opens the browser but STILL throws this exception so we can just ignore it.  If not this exception,
                // then attempt to open the URL in IE instead.
                catch (System.ComponentModel.Win32Exception)
                {
                    // sometimes throws exception so we have to just ignore
                    // this is a common .NET bug that no one online really has a great reason for so now we just need to try to open
                    // the URL using IE if we can.
                    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(IE_PROCESS, url);
                    System.Diagnostics.Process.Start(startInfo);
                    startInfo = null;
                }
            }
            catch (Exception)
            {
                // oper browser failed
                return false;
            }
            return true;
#endif
		}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:32,代码来源:MyBrowserHelper.cs

示例5: ShutdownComputer

 public void ShutdownComputer()
 {
     var pi = new System.Diagnostics.ProcessStartInfo();
     pi.FileName = GetPathToShutdownExe();
     pi.Arguments = @"/f /s /t 10";
     System.Diagnostics.Process.Start(pi);
 }
开发者ID:kakoskin,项目名称:VPNPanic,代码行数:7,代码来源:ShutdownController.cs

示例6: ExecuteCommandSync

        /// <summary>
        /// Executes a shell command synchronously.
        /// </summary>
        /// <param name="command">string command</param>
        /// <returns>string, as output of the command.</returns>
        public void ExecuteCommandSync(object command)
        {
            try {
                // create the ProcessStartInfo using "cmd" as the program to be run, and "/c " as the parameters.
                // Incidentally, /c tells cmd that we want it to execute the command that follows, and then exit.
                System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
                // The following commands are needed to redirect the standard output.
                //This means that it will be redirected to the Process.StandardOutput StreamReader.
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                // Do not create the black window.
                procStartInfo.CreateNoWindow = true;
                // Now we create a process, assign its ProcessStartInfo and start it
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();

                // Get the output into a string
                string result = proc.StandardOutput.ReadToEnd();

                Console.WriteLine(command);

                // Display the command output.
                Console.WriteLine(result);
            } catch (Exception objException) {
                // Log the exception
            }
        }
开发者ID:karthikeyanar,项目名称:dotnetsource,代码行数:33,代码来源:Program.cs

示例7: ExecuteControlPanelItem

    static public bool ExecuteControlPanelItem(String cmd) {
      // Discard control panel items
      String cpName = @"::{26EE0668-A00A-44D7-9371-BEB064C98683}";

      int cpIndex = cmd.IndexOf(cpName);

      if (cpIndex != 0) return false;

      //if (cmd.IndexOf(@"\::", cpIndex + cpName.Length) <= 0 && cmd != cpName) return false;
      if (!cmd.StartsWith(cpName)) return false;

      String explorerPath = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
      explorerPath += @"\Explorer.exe";

      cmd = cmd.Replace("Fonts", "::{BD84B380-8CA2-1069-AB1D-08000948F534}");

      System.Diagnostics.ProcessStartInfo procStartInfo =
          new System.Diagnostics.ProcessStartInfo(explorerPath, cmd);

      // Now we create a process, assign its ProcessStartInfo and start it
      System.Diagnostics.Process proc = new System.Diagnostics.Process();
      proc.StartInfo = procStartInfo;

      proc.Start();
      return true;
    }
开发者ID:rad1oactive,项目名称:BetterExplorer,代码行数:26,代码来源:Program.cs

示例8: Execute

        private static int Execute(string app, string workdir, string args)
        {
            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(app, args);
            psi.CreateNoWindow = true;
            psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            psi.WorkingDirectory = workdir;
            psi.RedirectStandardOutput = true;
            psi.RedirectStandardError = true;
            psi.UseShellExecute = false;

            System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
            p.WaitForExit(5 * 60 * 1000); //Wait up to five minutes
            if (!p.HasExited)
            {
                try { p.Kill(); }
                catch { }

                Console.WriteLine("Stdout: " + p.StandardOutput.ReadToEnd());
                Console.WriteLine("Stderr: " + p.StandardError.ReadToEnd());

                throw new Exception(string.Format("Application {0} hung", app));
            }

            Console.WriteLine();
            Console.WriteLine(p.StandardOutput.ReadToEnd());
            Console.WriteLine(p.StandardError.ReadToEnd());
            Console.WriteLine();

            return p.ExitCode;
        }
开发者ID:ZlayaZhaba,项目名称:XervBackup,代码行数:30,代码来源:Program.cs

示例9: processUpdateRequest

 // Method that runs update process
 public static void processUpdateRequest()
 {
     if(Common.Raffle != null && Common.Raffle.raffleIsActive())
     {
         Console.WriteLine("Update request placed in command queue.");
         return;
     }
     UpdateDetails details = WebCalls.downloadUpdateDetails().Result;
     if (!details.RequestSuccessful || !details.UpdateAvailable)
     {
         Console.WriteLine("RequestSuccessful: " + details.RequestSuccessful + ", UpdateAvailable: " + details.UpdateAvailable);
         return;
     }
     Console.WriteLine("Downloading new bot and updater...");
     WebCalls.downloadFile(details.DownloadLocation, "bot.exe");
     Console.WriteLine("new bot downloaded");
     WebCalls.downloadFile(details.UpdaterLocation, "updater.exe");
     Console.WriteLine("Finished! Starting updater and exiting.");
     System.Diagnostics.ProcessStartInfo pInfo = new System.Diagnostics.ProcessStartInfo();
     pInfo.FileName = "updater.exe";
     pInfo.ErrorDialog = true;
     pInfo.UseShellExecute = false;
     pInfo.RedirectStandardOutput = true;
     pInfo.RedirectStandardError = true;
     pInfo.WorkingDirectory = Path.GetDirectoryName("updater.exe");
     System.Diagnostics.Process.Start(pInfo);
     Environment.Exit(1);
 }
开发者ID:swiftyspiffy,项目名称:KrakenBot2,代码行数:29,代码来源:Update.cs

示例10: setupPortForwarding

    private void setupPortForwarding(int port) {
      string adbCommand = string.Format("adb forward tcp:{0} tcp:{0}", port);
      System.Diagnostics.Process myProcess;

#if UNITY_EDITOR_WIN
      string cmd = @"/k " + adbCommand + " & exit";
      Debug.Log ("Executing: [" + cmd + "]");
      myProcess = new System.Diagnostics.Process();
      System.Diagnostics.ProcessStartInfo myProcessStartInfo =
        new System.Diagnostics.ProcessStartInfo("CMD.exe", cmd);
      myProcessStartInfo.UseShellExecute = false;
      myProcessStartInfo.RedirectStandardOutput = true;
      myProcessStartInfo.CreateNoWindow = true;
      myProcess.StartInfo = myProcessStartInfo;
      myProcess.Start();
#else
      Debug.LogFormat("Trying to launch adb: {0}", adbCommand);
      myProcess = System.Diagnostics.Process.Start("bash", string.Format("-l -c \"{0}\"",
                                                                         adbCommand));
#endif
      myProcess.WaitForExit();
      int exitCode = myProcess.ExitCode;
      myProcess.Close();
      if (exitCode == 0) {
        Debug.LogFormat("adb process succeeded (exit code 0).");
      } else {
        Debug.LogErrorFormat("adb process FAILED (exit code {0}). Check that the Android SDK " +
            "is installed and that the adb command is in your PATH environment variable.",
            exitCode);
      }
    }
开发者ID:2954722256,项目名称:gvr-unity-sdk,代码行数:31,代码来源:EmulatorClientSocket.cs

示例11: Handle

        public static bool Handle(int instanceID, int line)
        {
            string path = AssetDatabase.GetAssetPath(EditorUtility.InstanceIDToObject(instanceID));
            string name = Application.dataPath + "/" + path.Replace("Assets/", "");

            if (name.EndsWith(".shader"))
            {
                string program = "";
                if (EditorPrefs.HasKey("ShaderEditor"))
                    program = EditorPrefs.GetString("ShaderEditor");

                if (System.IO.File.Exists(program))
                {
                    try
                    {
                        System.Diagnostics.Process process = new System.Diagnostics.Process();
                        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                        startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                        startInfo.FileName = program;
                        startInfo.Arguments = name;
                        process.StartInfo = startInfo;

                        return process.Start();
                    }
                    catch
                    {
                        return false;
                    }
                }
            }

            return false;
        }
开发者ID:CastleWSC,项目名称:AssetHelper,代码行数:33,代码来源:ShaderHandler.cs

示例12: RunGitCmd

        public void RunGitCmd(string serviceName, bool advertiseRefs, string workingDir, Stream inStream, Stream outStream)
        {
            var args = serviceName + " --stateless-rpc";
            if (advertiseRefs)
                args += " --advertise-refs";
            args += " \"" + workingDir + "\"";

            var info = new System.Diagnostics.ProcessStartInfo(System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["GitPath"]), args)
            {
                CreateNoWindow = true,
                RedirectStandardError = true,
                RedirectStandardInput = true,
                RedirectStandardOutput = true,
                UseShellExecute = false,
                WorkingDirectory = Path.GetDirectoryName(UserConfiguration.Current.Repositories),
            };

            using (var process = System.Diagnostics.Process.Start(info))
            {
                inStream.CopyTo(process.StandardInput.BaseStream);
                process.StandardInput.Write('\0');
                process.StandardOutput.BaseStream.CopyTo(outStream);

                process.WaitForExit();
            }
        }
开发者ID:kmhtoo,项目名称:Bonobo-Git-Server,代码行数:26,代码来源:GitController.cs

示例13: MainWindow

        public MainWindow()
        {
            _startedprocess = null;

            InitializeComponent();

            try
            {
                System.IO.StreamReader ipfile = new System.IO.StreamReader("patchip.cfg");
                string ipString = ipfile.ReadToEnd();
                ipfile.Close();

                System.Diagnostics.ProcessStartInfo psi =
                    new System.Diagnostics.ProcessStartInfo(@"patchingclient");
                psi.Arguments = " --IcePatch2.Remove=0 --IcePatch2.Endpoints=\"tcp -h "+ipString+" -p 10000\" .";
                psi.CreateNoWindow = true;
                psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                psi.UseShellExecute = true;
                _startedprocess = System.Diagnostics.Process.Start(psi);
            }
            catch (Exception ex)
            {
                labelInfo.Text = "Error during patching: " + ex.Message;
            }
        }
开发者ID:Rincevent,项目名称:lbanet,代码行数:25,代码来源:Form1.cs

示例14: RunApplication

        private static void RunApplication()
        {
            RegistryKey reg = Registry.CurrentUser.CreateSubKey(Program.KEY);
            string filePath = (string)reg.GetValue("FilePath", "");
            string fileArgs = (string)reg.GetValue("FileArgs", "");
            reg.Close();

            if (!File.Exists(filePath))
            {
                return;
            }

            //string filename = "D:\\Development\\WebkitScreenSaverWPF\\WebkitScreenSaverWPF\\bin\\Debug\\WebkitScreenSaverWPF.exe";
            System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(filePath, fileArgs);
            psi.WorkingDirectory = Path.GetDirectoryName(filePath);
            //psi.WorkingDirectory = "D:\\Development\\WebkitScreenSaverWPF\\WebkitScreenSaverWPF\\bin\\Debug\\";
            psi.RedirectStandardOutput = false;
            psi.RedirectStandardError = false;
            psi.RedirectStandardInput = false;
            // psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            psi.UseShellExecute = false;

            System.Diagnostics.Process listFiles;

            listFiles = System.Diagnostics.Process.Start(psi);
            //System.IO.StreamReader myOutput = listFiles.StandardOutput;
            listFiles.WaitForExit();

            //if (!listFiles.HasExited)
            //{
            //    listFiles.Kill();
            //}
        }
开发者ID:InsaneWookie,项目名称:ScreenSaverLauncher,代码行数:33,代码来源:Program.cs

示例15: formMain

        public formMain()
        {
            InitializeComponent();

            proInfo = new System.Diagnostics.ProcessStartInfo();
            pro = new System.Diagnostics.Process();
        }
开发者ID:japgo,项目名称:mygithub,代码行数:7,代码来源:formMain.cs


注:本文中的System.Diagnostics.ProcessStartInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。