6 个解决方案
#1
using System.Diagnostics;
如果是dos
Process.Start("cmd.exe");
如果是其他文件
Process.Start("绝对路径+文件名.exe");
------------------------------------
如何在c#中调用外部dos程序?
使用Process对象:
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="arj.exe" ;//需要启动的程序名
p.StartInfo.Arguments="-x sourceFile.Arj c:\temp";//启动参数
p.Start();//启动
if(p.HasExisted)//判断是否运行结束
p.kill();
如果是dos
Process.Start("cmd.exe");
如果是其他文件
Process.Start("绝对路径+文件名.exe");
------------------------------------
如何在c#中调用外部dos程序?
使用Process对象:
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="arj.exe" ;//需要启动的程序名
p.StartInfo.Arguments="-x sourceFile.Arj c:\temp";//启动参数
p.Start();//启动
if(p.HasExisted)//判断是否运行结束
p.kill();
#2
/// <summary>
/// 启动其他的应用程序
/// </summary>
/// <param name="file">应用程序名称</param>
/// <param name="workdirectory">应用程序工作目录</param>
/// <param name="args">命令行参数</param>
/// <param name="style">窗口风格</param>
public static bool StartProcess(string file,string workdirectory,string args,ProcessWindowStyle style)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(file,args);
startInfo.WindowStyle = style;
startInfo.WorkingDirectory = workdirectory;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return true;
}
catch(Exception e0)
{
MessageBox.Show("启动应用程序时出错!原因:" + e0.Message);
}
return false;
}
string parms = "" + GlobalObject.GetInstance().UserID + " " + GlobalObject.GetInstance().UserPassword;
if (PublicMethods.StartProcess(Application.StartupPath + @"\uptool\uptool.exe",Application.StartupPath + "\\UpTool",parms,ProcessWindowStyle.Normal))
{
Environment.Exit(0);
}
/// 启动其他的应用程序
/// </summary>
/// <param name="file">应用程序名称</param>
/// <param name="workdirectory">应用程序工作目录</param>
/// <param name="args">命令行参数</param>
/// <param name="style">窗口风格</param>
public static bool StartProcess(string file,string workdirectory,string args,ProcessWindowStyle style)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(file,args);
startInfo.WindowStyle = style;
startInfo.WorkingDirectory = workdirectory;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return true;
}
catch(Exception e0)
{
MessageBox.Show("启动应用程序时出错!原因:" + e0.Message);
}
return false;
}
string parms = "" + GlobalObject.GetInstance().UserID + " " + GlobalObject.GetInstance().UserPassword;
if (PublicMethods.StartProcess(Application.StartupPath + @"\uptool\uptool.exe",Application.StartupPath + "\\UpTool",parms,ProcessWindowStyle.Normal))
{
Environment.Exit(0);
}
#3
Process.Start("IExplore.exe", "http://community.csdn.net/Expert/topic/4021/4021327.xml?temp=.9493524");
#4
Process.Start("文件名");
#5
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo( );
startInfo.FileName = "执行EXE的文件名";
startInfo.Arguments = "参数数组";
System.Diagnostics.Process.Start( startInfo );
startInfo.FileName = "执行EXE的文件名";
startInfo.Arguments = "参数数组";
System.Diagnostics.Process.Start( startInfo );
#6
谢谢各位
#1
using System.Diagnostics;
如果是dos
Process.Start("cmd.exe");
如果是其他文件
Process.Start("绝对路径+文件名.exe");
------------------------------------
如何在c#中调用外部dos程序?
使用Process对象:
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="arj.exe" ;//需要启动的程序名
p.StartInfo.Arguments="-x sourceFile.Arj c:\temp";//启动参数
p.Start();//启动
if(p.HasExisted)//判断是否运行结束
p.kill();
如果是dos
Process.Start("cmd.exe");
如果是其他文件
Process.Start("绝对路径+文件名.exe");
------------------------------------
如何在c#中调用外部dos程序?
使用Process对象:
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName="arj.exe" ;//需要启动的程序名
p.StartInfo.Arguments="-x sourceFile.Arj c:\temp";//启动参数
p.Start();//启动
if(p.HasExisted)//判断是否运行结束
p.kill();
#2
/// <summary>
/// 启动其他的应用程序
/// </summary>
/// <param name="file">应用程序名称</param>
/// <param name="workdirectory">应用程序工作目录</param>
/// <param name="args">命令行参数</param>
/// <param name="style">窗口风格</param>
public static bool StartProcess(string file,string workdirectory,string args,ProcessWindowStyle style)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(file,args);
startInfo.WindowStyle = style;
startInfo.WorkingDirectory = workdirectory;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return true;
}
catch(Exception e0)
{
MessageBox.Show("启动应用程序时出错!原因:" + e0.Message);
}
return false;
}
string parms = "" + GlobalObject.GetInstance().UserID + " " + GlobalObject.GetInstance().UserPassword;
if (PublicMethods.StartProcess(Application.StartupPath + @"\uptool\uptool.exe",Application.StartupPath + "\\UpTool",parms,ProcessWindowStyle.Normal))
{
Environment.Exit(0);
}
/// 启动其他的应用程序
/// </summary>
/// <param name="file">应用程序名称</param>
/// <param name="workdirectory">应用程序工作目录</param>
/// <param name="args">命令行参数</param>
/// <param name="style">窗口风格</param>
public static bool StartProcess(string file,string workdirectory,string args,ProcessWindowStyle style)
{
try
{
Process myprocess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo(file,args);
startInfo.WindowStyle = style;
startInfo.WorkingDirectory = workdirectory;
myprocess.StartInfo = startInfo;
myprocess.StartInfo.UseShellExecute = false;
myprocess.Start();
return true;
}
catch(Exception e0)
{
MessageBox.Show("启动应用程序时出错!原因:" + e0.Message);
}
return false;
}
string parms = "" + GlobalObject.GetInstance().UserID + " " + GlobalObject.GetInstance().UserPassword;
if (PublicMethods.StartProcess(Application.StartupPath + @"\uptool\uptool.exe",Application.StartupPath + "\\UpTool",parms,ProcessWindowStyle.Normal))
{
Environment.Exit(0);
}
#3
Process.Start("IExplore.exe", "http://community.csdn.net/Expert/topic/4021/4021327.xml?temp=.9493524");
#4
Process.Start("文件名");
#5
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo( );
startInfo.FileName = "执行EXE的文件名";
startInfo.Arguments = "参数数组";
System.Diagnostics.Process.Start( startInfo );
startInfo.FileName = "执行EXE的文件名";
startInfo.Arguments = "参数数组";
System.Diagnostics.Process.Start( startInfo );
#6
谢谢各位