问题描述
我有一个批处理文件,该文件使用 Windows devcon .当我通过双击运行该批处理文件时,它运行正常.但是,我尝试从使用以下代码编写的C#程序中运行它:
I have a batch file which disables and enables some driver using windows devcon.when I run this batch file by double-clicking on it it works fine.However, I tried to run it from a C# program that I wrote using this line:
System.Diagnostics.Process.Start("C:/*path to file*/file.bat");
它运行良好,直到尝试打开devcon.exe并得到以下消息:
it runs fine until it tries to open the devcon.exe and I get the following message:
此后,它将继续平稳运行.
after that it continues to run smoothly.
从C#程序为什么不起作用的任何想法?
any ideas why it doesn't work from the C# program?
p.s由于IP问题,我无法发布批处理代码...
p.sI can't post the batch code due to IP issues...
推荐答案
好的,经过一番研究,我发现了这个简单的解决方案:只需在批处理代码的开头更改为devcon.exe的目录(使用cd命令),即:
ok, after a little bit of research I found this simple solution:simply changing to the directory of the devcon.exe (using cd command) at the beginning of the batch code, i.e:
cd "C:/*path to the directory of devcon.exe*"
#rest of the code
这篇关于批处理工作正常,但"Windows无法找到devcon.exe";在C#程序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!