创建bat文件及运行
创建bat文件及运行程序说明:创建bat文件及运行。
通过Process.Start方法运行bat文件后,其当前目录是程序运行目录。所以bat文件内的路径用完全路径最好.
private void btnCreate_Click(object sender, EventArgs e)
{
//写入bat文件。
File.WriteAllLines(txtFile.Text, txtContent.Lines, Encoding.UTF8);
}
private void btnExecute_Click(object sender, EventArgs e)
{
//执行bat文件
System.Diagnostics.Process P = new System.Diagnostics.Process();
P.StartInfo.FileName = txtFile.Text;
P.Start();
MessageBox.Show("已经运行bat文件.");
}

扫一扫加作者微信

通过Process.Start方法运行bat文件后,其当前目录是程序运行目录。所以bat文件内的路径用完全路径最好.
private void btnCreate_Click(object sender, EventArgs e)
{
//写入bat文件。
File.WriteAllLines(txtFile.Text, txtContent.Lines, Encoding.UTF8);
}
private void btnExecute_Click(object sender, EventArgs e)
{
//执行bat文件
System.Diagnostics.Process P = new System.Diagnostics.Process();
P.StartInfo.FileName = txtFile.Text;
P.Start();
MessageBox.Show("已经运行bat文件.");
}

扫一扫加作者微信


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网