forked from XINCGer/Unity3DTraining
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (33 loc) · 1.04 KB
/
Program.cs
File metadata and controls
39 lines (33 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Diagnostics;
namespace ProcessBat
{
/// <summary>
/// C#程序执行外部exe、bat文件
/// </summary>
class Program
{
static void Main(string[] args)
{
// 如果要运行时隐藏dos窗口,需使用下面的代码
//proc.StartInfo.UseShellExecute = false;
//proc.StartInfo.CreateNoWindow = true;
Process proc = null;
try
{
proc = new Process();
proc.StartInfo.FileName = @"./test.bat";
//proc.StartInfo.Arguments = string.Format("10");
//proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine("Exception Occurred :{0},{1}", ex.Message, ex.StackTrace.ToString());
}
}
}
}