Visual Studio窗体用户输入变量到Windows comand ..如何? [英] visual studio form user input variable to windows comand..how?

查看:79
本文介绍了Visual Studio窗体用户输入变量到Windows comand ..如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

迫切需要帮助...
我有一个批处理文件,该文件调用vbs框进行用户输入(或响应,主要是否),用户输入将转到文本文件,该文本文件被读入用于在操作中执行的bat变量(命令变量)
因此,我想...获得可视化的c ++ 2k10表达并使用所有字段制作一个表单,以便一次输入即可创建所有变量,并通过几个无线电按钮选择运行该变量的批处理文件并正确完成工作.. :)但不,现在我有了一个漂亮的表格,所有的位都将用户输入保存到我的私有int变量中,但是随后发现express似乎不支持在命令中运行它们……好了,Visual Studio 2k10最终试用版(花了30天的时间解决了这个问题),所以没有问题,我将用用户输入的形式从Google的谷歌上运行带有变量的命令,并复制粘贴正确的代码??? errrrm这是一个如此困难的问题吗?对我来说似乎很直截了当,但我可能会进行搜索...没有发现任何简单的示例或容易遵循的课程/视频...哦,糟糕...是的,我是网络管理员,而不是程序员,这很奇怪脚本或蝙蝠没有问题,但凭着世界上的所有意愿(以及30天的试用期),我不认为我可以得到我想要的东西……所以在这里非常感谢您的任何帮助:)

form1包含:
用户输入的文本框,它是文件夹位置(\\ server \ share \ or \ path)
用户类型\\ 127.0.0.1 \ c%\ temp
转到我定义的变量(int)%source%

按钮::现在就做

简单,现在运行:
净使用率z:%source%

只是一个简单的例子将对我有很大帮助:)

显然,该批处理包含的内容不止于此(并且可以正常工作)...但是凌乱地包含了4个vbs脚本和一个批处理文件,以将其全部与命令提示符下所需的一些输入一起保存,因为我什至不知道如何获取进入消息框大声笑,所以跳到单一表单解决方案对你们来说可能只是一小步,但对我来说却是一个巨大的飞跃.... :)

请请漂亮,请任何人认为他们可以引导盲人,那么我就是你的男人:D

在此先感谢(希望如此)

欢呼声和TakeItEasy
GazMan

Hi All,

desperately need help here...
I have a batch file that calls vbs boxes for user input (or response, yes no mainly) the user input goes to text file that is read into the bat variable used to execute in the opperation (command variables)
so i thought... get visual c++ 2k10 express and make a form with all the fields for usre input to create all the variables in one go and a couple of radio butttons to choose which batch file to run the variables in and job done right.. :) but no, now i have a pretty form with all the bits that save the user input to my private int variables but then discovered express doesn''t seem to support running them in a command... ok, visual studio 2k10 ultimate trial (got 30 days to sort this out lol) so no prob i''ll google running a command with variables from a form using user input and copy paste the code right??? errrrm is this such a difficult question? seems straight forward to me, but search as I may... no simple example or easy to follow course/video anywher to be found... oh-crap... yep I''m a network administrator not a programmer, the odd script or bat no prob but with all the will in the world (and a 30 day trial) i don''t think i can get what I''m lookin'' for... so any help greatly appreciated here :)
i.e.
form1 contains:
text box for user input, which is folder location (\\server\share\or\path)
user types \\127.0.0.1\c%\temp
which goes to my defined variable (int) %source%

button::do it now

easy, now run:
net use z: %source%

just a simple example of this would help me greatly :)

obviously the batch contains more than this (and works fine)... but messy with 4 vbs scrips and a batch file to hold it all together with some input needed back at the command prompt couse i don''t even know how to get that into a message box lol so jumping to a single forms solution may be one small step for you guys but one giant leap for me.... :)

please please pretty please anyone think they can guide the blind then I''m your man :D

thanks in advance (hopefully)

cheers and TakeItEasy
GazMan

推荐答案

不幸的是,这个问题很难理解.因此,对不起,如果我回答的是错误的问题;请联系我们.请不要为此怪我太多.

在我看来,您的问题是从您的应用程序运行子进程,例如您可以通过net use z: %source%这样的命令行执行操作,其中%source%是某些参数.我还认为您正在谈论.NET应用程序-请参阅我对该问题的评论.

如果这是问题,解决方案是这样:您需要使用类System.Diagnostics::Process::Start,请参见:
http://msdn.microsoft.com/en-us/library/system.diagnostics. process.aspx [^ ],
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx [ ^ ].

如果您有一个带参数的批处理文件(在批处理文件的代码中应表示为%1),则Process::Start的第一个参数应为该批处理文件的名称,第二个参数应为- )的批处理文件.

另外,您可能需要将子进程的输出重定向到流以使用主机程序中的输出.为此,您需要使用属性StandardOutputStandardError(以防万一出现错误:-).您可以在此处找到用于重定向的代码示例:
http://msdn.microsoft.com/en-us/library/system. diagnostics.process.standardoutput.aspx [ ^ ].

—SA
Unfortunately, this question is hard to understand. So, sorry if I''m answering a wrong question; please don''t blame me too much for that.

It seems to me that your problem is running a child process from your application, such as you would do by the command line like net use z: %source%, where %source% is some parameter. I also think that you are talking about .NET application — please see my comment to the question.

If this is the problem, the solution is this: you need to use the class System.Diagnostics::Process::Start, please see:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[^],
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx[^].

If you have a batch file with a parameter (should be represented as %1 in the code of a batch file), the first parameter of Process::Start should be a name of the batch file, and second parameter — the parameter(s) of the batch file.

Also, you may need to redirect the output of the child process to a stream to use the output in your host program. For this purpose, you need to use the properties StandardOutput and StandardError (just in case there are errors :-)). You can find a code sample for redirection here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^].

—SA


这篇关于Visual Studio窗体用户输入变量到Windows comand ..如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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