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


C# ProcessStartInfo.StartProcess方法代码示例

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


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

示例1: UpdateCurrentDeployment

        /// <summary>
        /// Updates the current deployment.
        /// </summary>
        /// <param name="deployment">The deployment.</param>
        /// <param name="message">The message.</param>
        /// <returns></returns>
        protected override bool UpdateCurrentDeployment(ApplicationDeployment deployment, ref string message)
        {
            //Call VSTOInstaller Explicitly in "Silent Mode"
            var installerPath = GetInstallerPath();
            if (installerPath == null)
            {
                message = "Cannot resolve VSTO Installer installation path";
                return false;                
            }
            var installerArgs = string.Format(" /S /I {0}", deployment.UpdateLocation.AbsoluteUri);

            var vstoInstallerOutput = new StringBuilder();

            var vstoStartInfo = new ProcessStartInfo(installerPath, installerArgs);
            var returnCode = vstoStartInfo.StartProcess((sender, e) => vstoInstallerOutput.Append((string) e.Data));

            message = vstoInstallerOutput.ToString();
            return returnCode == 0;
        }
开发者ID:JoyPeterson,项目名称:VSTOContrib,代码行数:25,代码来源:VstoClickOnceUpdater.cs

示例2: Uninstall

        private void Uninstall()
        {
            try
            {
                if (SelectedAddin.ManifestExists)
                {
                    var installerPath = VstoClickOnceUpdater.GetInstallerPath();

                    if (installerPath == null)
                    {
                        throw new InvalidOperationException("Cannot find VSTO Installer");
                    }
                    var installerArgs = string.Format(" /U \"{0}\"", SelectedAddin.Manifest);

                    var vstoInstallerOutput = new StringBuilder();

                    var vstoStartInfo = new ProcessStartInfo(installerPath, installerArgs);
                    var returnCode = vstoStartInfo.StartProcess((sender, e) => vstoInstallerOutput.Append(e.Data));

                    var message = vstoInstallerOutput.ToString();

                    if (returnCode != 0)
                    {
                        SelectedAddin.RegistryKey.DeleteKey();
                        MessageBox.Show(string.Format(
                            "Add-in was not installed through VSTOInstaller (probably visual studio instead), {0} was manually removed",
                            SelectedAddin.AddinName), "Success");
                    }
                    else
                    {
                        MessageBox.Show(string.Format("{0} uninstalled", SelectedAddin.AddinName), "Success");
                    }
                }
                else
                {
                    //Manifest doesn't exist, delete registry keys manually
                    SelectedAddin.RegistryKey.DeleteKey();
                    MessageBox.Show(string.Format("{0} uninstalled", SelectedAddin.AddinName), "Success");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Uninstalling");
                return;
            }

            _addins.Remove(SelectedAddin);
            SelectedAddin = null;
        }
开发者ID:roxberry,项目名称:VSTOContrib,代码行数:49,代码来源:MainWindowViewModel.cs


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