bat文件 执行路径

来源:互联网 发布:aecs6 mac中文破解版 编辑:程序博客网 时间:2024/05/17 08:53

最近用到了bat的一些东西,就是用C#程序调用bat文件时,

bat文件中的路径怎样动态的获取呢? 用 "~dp0"可以得到。

 

比如要注册一个名为test.dll的文件,dll文件和bat文件放在同一个文件夹下

bat文件写法:

  regsvr32 "%~dp0test.dll" -s

 

又比如要调用另外一个bat文件(文件名设为test.bat)

 写法:

 call "%~dp0test.bat"

 

 

 

顺便说一下,在C#中调用执行bat文件得方法:

System.Diagnostics.Process.Start(strFilePath);

原创粉丝点击