VB.NET tutorials : How to Process.start() Method to Run Embedded Resource File (Exe,Bitmap,Audio,Txt) using .NET for beginners
VB.NET For Beginners - How can i run (Exe, Txt, Audio, Images) Files from Embedded/Resources without extracting to file first using vb.net? If you want to execute an executable embedded file for example the .EXE files into your program, without extracting it to disk first, i think it's possible. But, you must know it is very, very, hard to do.
Please Read :
VB.NET Crud Operations with Metro Styles
What you have to do is, and note that I do not know all the details about this since I don't do this, but anyway :
then go to Resources Menu and Add Resources, please see the images below :
After done, back to Form1.vb and we will write all source code, just write all source code below in the Fomr1.Vb
Source Code Run Embedded Resource :
Just press "F5" keys to debugging your simple applications and let me know what happen.
if you still confusing with this tutorial, just view the video below :
Download Full Source Code Run Embedded Resource File
Please Read :
VB.NET Crud Operations with Metro Styles
What you have to do is, and note that I do not know all the details about this since I don't do this, but anyway :
- First you must Load the executable code into memory.
- Remap all addresses in the binary image, so that they're correct in relation to the base address you loaded the executable at.
- Possibly load external references, ie. other DLL's that executable needed.
- Then, Remap the addresses of those references.
- Possibly load references needed by the just loaded referenced DLL's
- Remap those dll's.
- Repeat 3 through 6 until done
- Call the code.
Run Embedded Resource File (Exe)
Just create a new project in your visual studio, then rename it with "EmbeddedResource", on the Form1.vb at your project add one Button look like this images :How to add Embedded Resources File?
at the Solution Explorer windows > right click on your project > click Properties.then go to Resources Menu and Add Resources, please see the images below :
After done, back to Form1.vb and we will write all source code, just write all source code below in the Fomr1.Vb
Source Code Run Embedded Resource :
Imports System.IO ' using system IO namespaces
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' declare the file name in resources filder
' NETConverter.exe is our resource files
Dim FilePath As String = Application.StartupPath & "\NETConverter.exe"
Using MsiFile As New FileStream(FilePath, FileMode.Create)
MsiFile.Write(My.Resources.NETConverter, 0, My.Resources.NETConverter.Length)
End Using
' open the resources files
Process.Start(FilePath)
End Sub
Public Function ProcessRunning(ByVal name As String) As Boolean
'Check if the process is runing. As ERROR handler.
For Each CloseProcess As Process In Process.GetProcesses()
If CloseProcess.ProcessName.StartsWith(name) Then
'process found running!!!
Return False
End If
Next
'process not found, So it is finaly been killed!!!
Return True
End Function
Private Sub Form1_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
'To kill the NETConverter.exe Process.
Dim MyProcess() As Process = System.Diagnostics.Process.GetProcessesByName("NETConverter")
For Each s As Process In MyProcess
' kill the process
s.Kill()
Next
'To delete the NETConverter.exe file from the directory.
If ProcessRunning("NETConverter") Then
Dim fileDeleted As String = My.Application.Info.DirectoryPath + "\NETConverter.exe"
If File.Exists(fileDeleted) = True Then
File.Delete(fileDeleted)
End If
Else : Form1_FormClosed(sender, e)
End If
End Sub
End Class
Just press "F5" keys to debugging your simple applications and let me know what happen.
if you still confusing with this tutorial, just view the video below :
Video tutorial How to Run Embedded Resource File (Exe,Bitmap,Audio,Txt)
Download Full Source Code Run Embedded Resource File
COMMENTS