Open a program from Resource

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
3 posts Page 1 of 1
Contributors
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Open a program from Resource
NeedHelp
How can i open a program from Resource?
NoWayIn
VIP - Donator
VIP - Donator
Posts: 444
Joined: Sat Nov 21, 2009 11:16 pm

Re: Open a program from Resource
NoWayIn
The best way ( as said by CodenStuff" ) is to extract the EXE and then run it
I haven't seen a program being launch from inside another program.

anyways, here's how you extract it from your program and then run it
Code: Select all
IO.File.WriteAllBytes("C:\NameOfFileToSaveAs.exe", My.Resources.NameOfApplicationResource)
        Process.Start("C:\NameOfFileToSaveAs.exe")

You can thank CodenStuff for that code!
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Open a program from Resource
mandai
You can run .Net functions from an exe/dll resource file, though running non-.net programs is a bit harder.
Code: Select all
Dim cur As Assembly = Assembly.GetAssembly(GetType(Module1))

Dim s As Stream = cur.GetManifestResourceStream("ConsoleApplication1.test.exe")
If s Is Nothing Then
     MsgBox("can't find your exe in embedded resources.")
     Return
End If

Dim ProgBytes(s.Length) As Byte
s.Read(ProgBytes, 0, ProgBytes.Length)
s.Close()

Dim nxt As Assembly = Assembly.Load(ProgBytes)
Dim method As MethodInfo = nxt.EntryPoint
Dim inst As Object = nxt.CreateInstance(method.Name)
method.Invoke(inst, Nothing)
3 posts Page 1 of 1
Return to “Tutorial Requests”