如何从app.config文件调用批处理文件 [英] How to call batch file from app.config file

查看:205
本文介绍了如何从app.config文件调用批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道如何从app.config文件中调用第三方批处理文件.请帮帮我.



在我的App.Config文件中,我写了:



I want to know how to call a third party batch file from the app.config file. please help me out.



In my App.Config File i have written:

<add key="BatchFile" value="qs.bat">



在我的.cs中:



in my .cs:

string sValue = ConfigurationManager.AppSettings["BatchFile"];
process.start(sValue);



但它不起作用.


谢谢.



but it is not working.


Thank you.

推荐答案

app.config将不会执行任何操作...
好了,您的应用程序可以从配置文件中读取设置.使用ConfigurationManager类.
读取该批处理文件的路径后,将其启动.为此,请使用Process.Start.
app.config won''t execute anything...
Well, your application can read settings from the config file. Use the ConfigurationManager class.
After reading the path of that batch file, have it start it. Use Process.Start for that purpose.


尝试

Try

System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = sValue; 
proc.StartInfo.UseShellExecute = true;
proc.Start();


请参阅此内容!
http://stackoverflow. com/questions/662000/changing-values-in-web-config-with-a-batch-file-or-in-net-code [
See this one!
http://stackoverflow.com/questions/662000/changing-values-in-web-config-with-a-batch-file-or-in-net-code[^]
Thank u.


这篇关于如何从app.config文件调用批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆