如何在单击按钮时运行.bat文件的内容 [英] How to run content of .bat file on button click

查看:294
本文介绍了如何在单击按钮时运行.bat文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我无法运行.bat文件.我尝试了执行bat文件的所有可能方式.
我在该批处理文件中有一个.bat文件,我有一个.exe文件和配置文件(.ini文件).
当我单击按钮时,我希望该特定的.bat文件必须执行,即应执行exe文件.
当我执行process.start(batfilepath)时,它正在读取显示exe和ini文件的bat文件中的内容,并在内部或外部命令中弹出消息.exe.
当我使用process.startinfo时,什么都没做..

谁能帮忙...

Hello,
I am unable to run the .bat file. I tried all possible ways of executing bat file.
I have one .bat file inside that batch file i have one .exe file and config file(.ini file).
When i click the button i want that particular .bat has to get executed i.e exe file should execute.
when i execute process.start(batfilepath), it is reading the content inside bat file showing exe and ini file and popping message .exe in not internal or external command.
when i used process.startinfo nothing is done..

Could any one please help...

推荐答案

HI
试试这个

HI
try this

Dim ps As New ProcessStartInfo("cmd.exe")
ps.Arguments = "yourbatfile.bat"
Process.Start(ps)


如果您想从命令行启动* .bat或* .exe文件,则需要定义该文件的完整路径和名称.
运行cmd.exe时显示:
C:\Windows\system32.exe-命令窗口的标题
C:\Documents And Setting\your_username>_-在命令窗口中.
当您尝试执行blablabla.bat并且blablabla.bat不在此文件夹中时,什么都没有发生.

要从命令行执行任何可执行文件,请使用:
If you would like to start *.bat or *.exe file from commandline, you need to define full path and name to this file.
When you run cmd.exe it shows:
C:\Windows\system32.exe - title of command window
C:\Documents And Setting\your_username>_ - inside command window.
When you trying to execute blablabla.bat and blablabla.bat is not in this folder, nothings happend.

To execute any executable file from commandline, use:
C:\Documents And Setting\your_username>rem cmd is waiting for your command 
C:\Documents And Setting\your_username>chdir "path_to_bat" 
path_to_bat>short_file_name.bat 
path_to_bat>rem that's all 



现在知道了吗?

您可以使用 Shell函数 [ ^ ]



Do you understand now?

You can call this *.bat using Shell function[^] too.


这篇关于如何在单击按钮时运行.bat文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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