Page 1 of 1

Open a program from Resource

Posted: Mon Apr 12, 2010 3:24 pm
by NeedHelp
How can i open a program from Resource?

Re: Open a program from Resource

Posted: Mon Apr 12, 2010 5:31 pm
by 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!

Re: Open a program from Resource

Posted: Sun May 02, 2010 7:25 pm
by 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)