本文整理汇总了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;
}
示例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;
}