如何将参数传递给VS2017 exe [英] How t osend a parameter to a VS2017 exe

查看:556
本文介绍了如何将参数传递给VS2017 exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2017中有一个运行报告的Windows窗体项目。我希望能够从批处理文件运行程序(exe)并将参数从批处理文件发送到程序,并让程序检索该参数并根据
执行某些操作。我如何实现这一点(在批处理中发送参数的格式以及如何编写vs2017项目以获取该信息)。我在调试下发现了一些关于命令行参数的信息,但这听起来像是从
程序发送参数,而不是发送参数。

I have a windows form project in VS2017 that runs a report. I want to be able to run the run the program (exe) from a batch file and send a parameter from the batch file to the program and have the program retrieve that parameter and do something based on it. How do I accomplish this (both the format of sending the parameter in the batch and how to code the vs2017 project to get that information). I found some info about the command line arguments under debug but that sounds like sending parameters from the program, not to.

谢谢

推荐答案

你好J-Bal,

Hi J-Bal,

>>我找到了一些关于命令行参数的信息调试,但这听起来像是从程序发送参数,而不是发送参数。

>>I found some info about the command line arguments under debug but that sounds like sending parameters from the program, not to.

根据您的描述,您希望运行程序(exe)来自批处理文件并将批处理文件中的参数发送到程序,并让程序检索该参数并根据它执行某些操作。

According to your description, you want to run the program (exe) from a batch file and send a parameter from the batch file to the program and have the program retrieve that parameter and do something based on it.

据我所知,您可以运行该程序(exe)通过批处理文件,以下代码供您参考,但winform app是客户端应用程序,无法从外部接收参数。

As far as I know, you could run the program(exe) via a batch file, the following code for your reference, but winform app is client application, which could not receive the parameter from external.

start "windowTitle" fullPath/file.exe

我建议您可以将参数写入文本文件,然后winform应用程序在启动时从文本中读取参数。有关将参数写入txt文件的更多信息,请参阅:

I would suggest that you could write the parameter into a text file, then winform application read the parameter from text when it launch. For more information about write parameter into txt file, please refer to:

https://stackoverflow.com/questions/1115508/batch-find-and-edit-lines-in-txt-file

祝你好运,

张龙武


这篇关于如何将参数传递给VS2017 exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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