Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simply gui to control batch file in Windows 1

Status
Not open for further replies.
Mar 6, 2003
157
JO
I'm totally new to VB.NET. I'd like to know if there is any quick way to build a very simple GUI interface to be able to control a Windows batch file.

For example, I have the following batch file command:

xcopy c:\Report_Target\report.ppx e:\Report_Destination\

In my case, since the paths or report filenames are constantly changing, how can I build a simple GUI for the user to be able to change either paths or filenames instead of constantly opening up the batch file to make these changes?

Once I know how to begin, I'd be able to figure out how to adapt the program/GUI if I have any other types of batch file commands or parameters that need modifications often.

I hope I'm making sense.


Thanks so much in advance for any help,
Shawn
 
cheap and easy:

throw 2 text boxes, 2 labels and a button on a form. use the labels to identify the text boxes as source file and destination. on the button click event do this:

System.Diagnostics.Process.Start("xcopy " & textbox1.text & " " & textbox2.text)


there are tons of other ways to do this and to improce on it. Including using the System.IO name space to do the file copy, and using a file dialog for selecting the source file and destination file. Have fun with it!

-Rick

----------------------

[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick,

Great! Exactly what I needed. How much more complicated would it be to give the user the possibility to browse to the target and destination paths as opposed to having them type in the paths?

Much appreciated,
Shawn
 
stick a button next to each of the text boxes, set the text of the button to "..." (the traditional 'Browse' text). Then add an OpenFileDialog and SaveFileDialog to the form. On the click event of the 2 new "..." buttons, have them open the Open and Save dialogs respectively, and set the text box's text to the value retreived from the Open and Save dialogs (I think it's .file)

Again, there are many way to go above and beyond this, play with it and have fun!

-Rick

----------------------

[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Rick,

I was getting all kinds of errors in the code. As soon as I entered the following for my button code, I got my code to work...

System.Diagnostics.Process.Start("xcopy.exe", TextBox1.Text & " " & TextBox2.Text)


Thanks,
Shawn
 
Rick,

Please take a look at my button code which gets assigned to the textbox text:

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If OpenFileDialog2.ShowDialog() = DialogResult.OK Then
Dim sr As New System.IO.StreamReader(OpenFileDialog2.FileName)
TextBox2.Text = OpenFileDialog2.FileName
sr.Close()
End If
End Sub


Is there a way, instead of assigning the value of the path including the file, to assign JUST the current directory to which the user is browsing? It appears that the file dialog box requires the user to select a specific file before pressing OK. However, I just want the user to browse to a specific folder and then to capture that folder PATH to the textbox text.

Thanks,
Shawn
 
A quick google search pulled up a reference to a FolderBrowserDialog. Unfortunatly it's only available in .Net 1.1 (VS 2k3) so I can't look it up. I'm running on VS 2k2 here :(

-Rick

----------------------

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
Hi Rick,

I also only have .NET 1.0. Does that mean that I cannot use this BrowseFolder class?

Is there any alternative?

Regards,
Shawn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top