using System.Diagnostics;
/// <summary>
/// 执行程序
/// </summary>
/// <param name="fileName">程序路径</param>
/// <param name="arguments">执行参数</param>
public void ProcessStart(string fileName, string arguments)
{
ProcessStartInfo psi = new ProcessStartInfo()
{
FileName= fileName,
Arguments = arguments,
WindowStyle = ProcessWindowStyle.Hidden
};
Process.Start(psi);
}
调用:
ProcessStart(@"C:\WINDOWS\system32\cmd.exe", @"net use \\172.16.17.1 /user:username password");
/// <summary>
/// 执行bat文件
/// </summary>
/// <param name="fileName">文件名</param>
public void ExcuteBat(string fileName)
{
Process process = new Process();
process.StartInfo.CreateNoWindow = false;
process.StartInfo.FileName = fileName;
process.Start();
}
调用:
ExcuteBat("D:\\netuse.bat");
C# 执行程序
最新推荐文章于 2024-07-03 19:53:45 发布