C#中执行批处理文件(*.bat)的方法代码
时间:2022-12-01 10:25:01
static void Main(string[] args)
{
Process proc = null;
try
{
string targetDir = string.Format(@"D:\adapters\setup");//this is where mybatch.bat lies
proc = new Process();
proc.StartInfo.WorkingDirectory = targetDir;
proc.StartInfo.FileName = "mybatch.bat";
proc.StartInfo.Arguments = string.Format("10");//this is argument
proc.StartInfo.CreateNoWindow = false;
proc.Start();
proc.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine("Exception Occurred :{0},{1}", ex.Message,ex.StackTrace.ToString());
}
}
如果要运行时隐藏dos窗口,需使用下面的代码
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
标签:批处理,bat
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Android实现本地Service方法控制音乐播放
2021-12-16 07:22:31
![](https://img.aspxhome.com/file/2023/0/129140_0s.jpg)
RollViewPager图片轮播效果开源框架使用方法详解
2021-12-06 07:22:59
![](https://img.aspxhome.com/file/2023/8/139398_0s.gif)
详解Spring Data JPA使用@Query注解(Using @Query)
2023-11-29 14:49:34
Android编程之手机壁纸WallPaper设置方法示例
2023-09-27 20:51:10
C# WinForm国际化实现的简单方法
2023-08-07 04:29:34
![](https://img.aspxhome.com/file/2023/2/92902_0s.jpg)
Android编程之SharedPreferences文件存储操作实例分析
2023-07-18 04:07:31
![](https://img.aspxhome.com/file/2023/3/138923_0s.png)
Eclipse+Java+Swing+Mysql实现工资管理系统
2023-07-26 08:51:05
![](https://img.aspxhome.com/file/2023/0/57960_0s.png)
Spring Boot使用Allatori代码混淆的方法
2023-11-24 16:34:55
![](https://img.aspxhome.com/file/2023/0/59080_0s.jpg)
android Handler详细使用方法实例
2022-11-29 01:35:12
![](https://img.aspxhome.com/file/2023/3/101853_0s.jpg)
解读classpath读取resources目录下的文件
2023-01-25 05:49:36
![](https://img.aspxhome.com/file/2023/2/85482_0s.png)
C#异常捕获机制图文详解
2023-05-22 19:39:20
![](https://img.aspxhome.com/file/2023/5/116445_0s.png)
Kotlin启动协程的三种方式示例详解
2023-06-07 02:58:53
![](https://img.aspxhome.com/file/2023/6/117106_0s.png)
Java jvm中Code Cache案例详解
2022-02-04 17:00:53
IDEA 2020.1 版自动导入MAVEN依赖的方法(新版MAVEN无法自动导入/更新POM依赖、MAVEN设置自动更新、自动更新快捷键)
2022-08-27 09:31:22
![](https://img.aspxhome.com/file/2023/4/88504_0s.png)
ThreadLocal数据存储结构原理解析
2023-04-27 19:54:55
![](https://img.aspxhome.com/file/2023/4/128234_0s.png)
Java内存模型中的虚拟机栈原理分析
2022-02-08 04:41:33
![](https://img.aspxhome.com/file/2023/0/81990_0s.jpg)
C# 中如何取绝对值函数
2022-11-17 10:43:53
一次排查@CacheEvict注解失效的经历及解决
2023-11-13 12:07:23
![](https://img.aspxhome.com/file/2023/0/59200_0s.png)
浅谈C#指针问题
2022-07-19 17:06:00
java后台接受到图片后保存方法
2023-06-03 09:23:04
![](https://img.aspxhome.com/file/2023/3/71853_0s.png)