Opening other files

darryl14

New member
Joined
Feb 23, 2005
Messages
4
Programming Experience
Beginner
right... what i want to do is click a button and it run another file that is already on the harddisk, how can i do this? Could someone please post some sample code. I dont know if its relevant but the files i want to run are batch files. Thankyou.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Use : process.start("File name")
If your batch files have arguments you can use them as well like this : process.start("File name", "Args")

TPM
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
or use an OpenFileDialog to have the user select a file to be opened then you can use a streamreader and whatnot to actually open/manipulate the file contents
 

darryl14

New member
Joined
Feb 23, 2005
Messages
4
Programming Experience
Beginner
right... im not sure that the process.start() works, how would it work with a batch file

say the file were in C:\batchfile1.bat for simplicitys sake. How would i go about running this file. Would it go some thing like:

process.start(batchfile1.bat)

or is it more complex, because i just tried something like that and it said that batchfile1 is not declared. What do i need to do.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
shell(batchfile1.bat) would work as well or system.diagnostics.process.start(batchfile1.bat) would also work
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
VB.NET:
Private Sub btnRunBatch (...) Handles btnRunBatch.Click
   Shell("batchfile1.bat", AppWinStyle.NormalFocus)
End Sub
 
Top Bottom