הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Saturday, February 22, 2014 7:26 PM
Hello.
So I have batch file that contains series of commands. (about 10) -
I've decided that I would like to create simple gui for this tool - simply one button that would execute commands one after another (when command A is finished command B starts)
Thing is that I do not want to use SendKey method, I am looking for a way that would not even show command prompt window. Is there any way to achieve this?
I am obviously beginner, so any help is welcome :).
Thank you very much!
All replies (3)
Monday, February 24, 2014 9:45 AM ✅Answered
What batch commands are in that file ?
a simple way would just be
Dim procID As Integer procID = Shell("C:\yourbatfile.bat", AppWinStyle.Hide)
A better way would be to use the process class
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx
Monday, February 24, 2014 1:18 PM ✅Answered
Hi,
You can ether do as Rbie has shown and run your batch file or you can run a cmd window and execute your commands 1 after the other like below using the Arguments. You separate each command with an & sign. The /c will make it run your commands and then close the cmd window automatically. If you want the cmd window to stay opened after running your commands you can replace the /c with /k.
I ran 4 commands in this example.
- i change the directory to C:\TestFolder
- clear the screen
- print Hello in the cmd window
- write the directory to a file called TextFile.txt
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Execute 4 Commands |/c| 1 |&| 2 |&| 3 |&| 4 |
Dim cmds As String = "/c cd C:\TestFolder & cls & echo Hello & dir > textfile.txt"
Process.Start("cmd.exe", cmds)
End Sub
Monday, February 24, 2014 9:38 AM
Hi,
I have moved this thread to Visual Basic forum for better support.
Thanks
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.