|
-
Aug 17th, 2007, 04:11 AM
#1
Thread Starter
Member
Problem Fixed: Still need 1 last question answered, How do I save the config.
Ok this might be a little bit hard to explain. So ill try my best.
Ok I run a private server of world of warcraft and I goof around with VB ALOT.
Until now I never had any use for what i'm about to ask hence why im asking it but what I need to know is.
Theres 2 things that have to be running for the World of Warcraft Private Server to stay up, Ascent.exe / LoginServer.exe
Now I like making neat little programs so I just wanted 2 buttons, that when I click the one labeled Ascent, it runs Ascent.exe located Desktop/Repack/Ascent
and when I hit the second button labeled Server it runs LoginServer.exe located at the same place.
If you also wanna help me, How do I make a check box so that when its checked it monitors if 1 of the 2 go down and it will restart it without me having to.
Thanks I tried to explain it best I can.
- Abomination
Last edited by Abomination; Aug 17th, 2007 at 06:56 AM.
-
Aug 17th, 2007, 04:53 AM
#2
Re: How do I run a program outside of VB.
I would suggest creating two Process objects in the designer, which reduces the amount of code considerably. Add your two Process objects to your form from the Toolbox. Open the properties window and set the appropriate properties. You must set EnableRaisingEvents to True at least. You may want to expand the StartInfo node and set its FileName property if you want to hard-code the executable paths. Otherwise you'll set them in code. That would look like so:
vb.net Code:
Me.Process1.StartInfo.FileName = pathToExe
Now select both Processes in the designer, open the Properties window, click the Events button and then double-click the Exited event. That will create a common event handler for both Processes. In that event handler you'd put code like this:
vb.net Code:
If Me.CheckBox1.Checked Then
DirectCast(sender, Process).Start()
End If
That will restart the exited process if the CheckBox is checked. You'd then add your two Buttons, select them both in the designer and double-click one of them to create two Click event handlers. In each event handler you'd put code like this:
vb.net Code:
If Process.GetProcessesByName("process name here").Length = 0 Then
'There are no processes with that name currently running so start one.
Me.Process1.Start()
End If
-
Aug 17th, 2007, 06:19 AM
#3
Thread Starter
Member
Re: How do I run a program outside of VB.
Thanks that answered everything. But I wanna do something else also
EDIT: I now know how due to handy dandy search button =)
I wanna make a browse thing so that they can set where it is.
I tried this but it didnt work
vb Code:
Me.Process1.StartInfo.Filename = OpenFileDialog1.ShowDialog
it just makes it like put "1" as the path how do I get the path they actually went to and the file. e.g., "c:\blah\blah.exe"
Last edited by Abomination; Aug 17th, 2007 at 06:27 AM.
Reason: Fixed
-
Aug 17th, 2007, 06:38 AM
#4
Re: How do I run a program outside of VB.
Showdialog returns a DialogResult. you should check this result to make sure that it was returned ok and then get the OpenFiledialog.FileName. You would do something like this
Code:
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.Process1.StartInfo.Filename = OpenFileDialog1.FileName
End If
-
Aug 17th, 2007, 06:45 AM
#5
Thread Starter
Member
Re: How do I run a program outside of VB.
Ok so very last question.
How do I make it so that it saves the location that the person chose so they don't have to every time they run it. Thanks.
-
Aug 17th, 2007, 08:33 PM
#6
Re: Problem Fixed: Still need 1 last question answered, How do I save the config.
Add a setting to your application of type String and bind it to the FileName property of your OpenFileDialog. Now whenevr you open the OFD the value of that setting will be used as the path and if the user selects a different path that will automatically be saved. Note that you should add your OFD to the form in the designer in order to bind the property to the setting, rather than create it in code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|