[Help]Run Application from resources
I have an exe program in my resource folder. How can i run it when i click a button?
Try this
Name Space
[php]
Imports System.IO
[/php]
Now this in a button click (or whet ever triggers the event)
[php]
Dim RPath As String = Application.StartupPath & "\File.exe" 'File.exe will be a temp name given to your exe, you can make it anything you want, or keep it as is.
' Will create the file with the given name
Using CreateFile As New FileStream(RPath, FileMode.Create)
CreateFile.Write(My.Resources.YourResource, 0, My.Resources.YourResource.Length)
End Using
' Start the application
Process.Start(RPath)
[/php]
Note: "Your Resource" in my code example above needs to be the EXE name without the exe extension, so for example, if you add notepad.exe as a resource, then the code would be
[php]
Dim RPath As String = Application.StartupPath & "\File.exe"
Using CreateFile As New FileStream(RPath, FileMode.Create)
CreateFile.Write(My.Resources.Notepad, 0, My.Resources.Notepad.Length)
End Using
Process.Start(RPath)
[/php]
added to snippets vault post 1