Results 1 to 6 of 6

Thread: Make .exe resource run while Form1_load[HELP]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Make .exe resource run while Form1_load[HELP]

    How can i make it so that when i load my form, it loads a .exe file along with it that is in my Resource folder? Thanks

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: Make .exe resource run while Form1_load[HELP]

    Is this possible or no ?

  3. #3
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: Make .exe resource run while Form1_load[HELP]

    I don't know of any clean way to do this. But this will work assuming you added the exe into your resources:

    vb.net Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim tempFileName As String = System.IO.Path.GetTempFileName() & ".exe"
    3.         Using fs As New FileStream(tempFileName, FileMode.Create)
    4.             fs.Write(My.Resources.exeNameHere, 0, My.Resources.exeNameHere.Length)
    5.         End Using
    6.         Process.Start(tempFileName)
    7.     End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: Make .exe resource run while Form1_load[HELP]

    i get FileStream is not defined

  5. #5
    Addicted Member
    Join Date
    Apr 2009
    Location
    Near Dog River (sorta)
    Posts
    160

    Re: Make .exe resource run while Form1_load[HELP]

    For my current app, I added as a resource, the CHM help file, so that in case the copy distributed with the appilcation is lost, it can be re-written to disk. Here is the code that does that:


    vb.net Code:
    1. Dim Writer As New IO.FileStream(Application.StartupPath & "\filename.chm", IO.FileMode.Create)
    2.  
    3. Writer.Write(My.Resources.RESOURCE-NAME-HERE, 0, My.Resources. RESOURCE-NAME-HERE.Length)
    4.  
    5. Writer.Close()

    Change the chm to exe and see what you get.


    Edit: I see that my code is the same as ForumAccount's code. Try adding the Close function, though. In addition, I also have "Imports System.Deployment.Application" at the top of my code.
    Last edited by JugglingReferee; May 27th, 2009 at 02:58 PM.
    PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
    Help Files: HelpMaker · Dr. Explain · Create Icons: IcoFX


    "Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2009
    Posts
    96

    Re: Make .exe resource run while Form1_load[HELP]

    Ugh no luck its ok i changed my mind, thx for the help both of you ! =]

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