Results 1 to 6 of 6

Thread: Problem Fixed: Still need 1 last question answered, How do I save the config.

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    47

    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.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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:
    1. 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:
    1. If Me.CheckBox1.Checked Then
    2.     DirectCast(sender, Process).Start()
    3. 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:
    1. If Process.GetProcessesByName("process name here").Length = 0 Then
    2.     'There are no processes with that name currently running so start one.
    3.     Me.Process1.Start()
    4. End If
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    47

    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:
    1. 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

  4. #4
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2007
    Posts
    47

    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.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width