use process.start based on settings file?

aruben27

New member
Joined
May 14, 2010
Messages
3
Programming Experience
Beginner
Hi all,

My first post! im quite new to programming but loving every minute of it.
Basically i want to open another exe file from vb.net 2010. i can do it normally using

system.Diagnostics.Process.Start _
("c:\winamp.exe")

if winamp for example is installed on another pc in another location i want to run it from my program but i want there to be sort of like a settings.txt file where you can edit the path to winamp and my program should first read the path set in the settings file and then open accordingly. how do i go about doing this?
Any help would be greatly appreciated.

Cheers


btw it would be great if you could point me in the right direction for making a windows form where one can edit the settings file within my program without editing the settings file in notepad
 
You can for example have a 'winamp' String user setting in your application settings, see My.Settings Object, which you populate with a OpenFileDialog to let user browse to and select the correct path, then Process.Start that.
For FileOK event (after showing dialog with ShowDialog method:
VB.NET:
My.Settings.winamp = FileDialog.FileName
VB.NET:
Process.Start(My.Settings.winamp)
 
thanx

hi, thanks for ur reply, im starting to understand how it works. i keep getting an error though when compiling

"property winampath is readonly"

This is the code so far :

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myStream As Stream = Nothing
Dim openFileDialog As New OpenFileDialog()

openFileDialog.InitialDirectory = "c:\"
openFileDialog.FilterIndex = 2
openFileDialog.RestoreDirectory = True
If openFileDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
My.Settings.winamppath = openFileDialog.FileName
End If
End Sub
 
i keep getting an error though when compiling

"property winampath is readonly"
That would only happen if you changed the setting from User scope (which you need, as I said) to Application scope (readonly).
 
Back
Top