如何通过在vb.net中运行批处理文件来执行代码? [英] How to execute code through running Batch file in vb.net?

查看:169
本文介绍了如何通过在vb.net中运行批处理文件来执行代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

团队,

我想简短地了解如何通过批处理文件执行vb.net代码.
通过Test.exe文件传递3个参数(项目文件,XML文件和Generate_Reports).

下面的代码执行Test.Exe文件,然后选择Text.PRJ文件.
选择Test.PRJ文件后,Test.XML文件将自动上传,
最终生成HTMLReport.

Hi Team,

I want to know briefly how to execute vb.net code through Batch file.
Passing 3 arguments (Project file, XML file and Generate_Reports) with Test.exe file.

Below code executing Test.Exe file, and choose Text.PRJ file.
Once chose Test.PRJ file then Test.XML file upload automatically,
Finally generate HTMLReport.


Test Batch Script:

@echo off
cls
echo Launching Application.....
start Test.exe "C:\test.prj" "test.xml" "TestReport"
exit


如何通过上述脚本调用VB.Net代码,如何在VB.Net代码中传递这些参数.
请帮我做代码和解释.

在此先感谢.


How to call VB.Net code through above script, How to pass these parameters in VB.Net code.
Please help me how to do code and explain.

Thanks in Advance.

推荐答案

您已经知道如何执行,您的问题仅是关于获取命令行参数.命令行已经从shell传递到应用程序.您只需要阅读参数即可.

本质上,有两种不同的方式:1)应用程序的入口点(Main静态方法)可以具有参数args; 2)方法System.Environment.GetCommandLineArgs.请参阅:
http://en.wikipedia.org/wiki/Main_function#C.23 [ ^ ],
http://msdn.microsoft.com/en-us/library/system.environment. getcommandlineargs.aspx [ ^ ].

请注意,这些方法会产生不同的结果:在第二种情况下,在索引0处提供了一个附加参数,即应用程序的输入程序集的主要可执行模块的位置.

顺便说一句,对于命令行的解析,请参阅我关于该主题的详细文章,以及我在本文中引用的另一篇CodeProject文章:
基于枚举的命令行实用程序 [
You already know how to execute, your question is only about getting the command-line arguments. The command-line is already passed from the shell to the application; you only need to read the arguments.

Essentially, there are two different ways: 1) entry-point of your application (Main static method) can have the parameter args; 2) the method System.Environment.GetCommandLineArgs. Please see:
http://en.wikipedia.org/wiki/Main_function#C.23[^],
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx[^].

Note that these methods gives different results: in second case, at index 0 an additional argument is provided, the location of the main executable module of your entry assembly of your application.

By the way, for parsing of the command line, please see my detailed article on the topic, and also one more CodeProject article I referenced in my article:
Enumeration-based Command Line Utility[^].

—SA




请通过此链接,它将说明您所需的所有详细信息:
Hi,

Please go through this link it will explain all details you required :http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2[^]

Good luck...


这篇关于如何通过在vb.net中运行批处理文件来执行代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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