How to run a .exe from inside a VB 2008 project?

a little help here please?

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 37562 Views - Last Post: 22 August 2011 - 04:41 AM Rate Topic: -----

#1 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

How to run a .exe from inside a VB 2008 project?

Posted 20 October 2008 - 05:50 AM

Hi,
i was wondering if anyone knows how to get a VB 2008 project to run a .exe from withinside it???

say i wanted a muti installer...with the installer packages embedded inside it....is it possible to call tghe .exe by clicking a button?

i hope you understand what im saying.
Is This A Good Question/Topic? 0
  • +

Replies To: How to run a .exe from inside a VB 2008 project?

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to run a .exe from inside a VB 2008 project?

Posted 20 October 2008 - 06:37 AM

Take a look at this article on Bootstrapping with VB.NET. Though this article is written for VB 2005 I believe it works the same way for 2008
Was This Post Helpful? 0
  • +
  • -

#3 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 22 October 2008 - 09:00 AM

this didn't help sorry
Was This Post Helpful? 0
  • +
  • -

#4 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 22 October 2008 - 04:40 PM

I am not following your OP to well, at first I thought you just wanted to know how to start a process, then it sounded like you wanted the setup program to allow the user to select which MSI file to install during the setup, however I am more leaning towards you wanting to embed msi files within an exe then have that application execute them when the user clicks a button within the application.

Maybe try to clarify your requirements a bit more. And if it is the later what are you really trying to accomplish.

This post has been edited by magicmonkey: 22 October 2008 - 04:41 PM

Was This Post Helpful? 0
  • +
  • -

#5 DCB  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 1
  • Joined: 22-October 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 22 October 2008 - 05:41 PM

'will run an executable file called myfile.exe
Process.Start("c:\myTestFolder\myfile.exe")

Works for me.
Was This Post Helpful? 2

#6 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 03:48 AM

Ok... i am trying to embed a .msi file

and i want that so when a user clicks "Install" it opens up the embeded .msi file

i hope this makes more sense
Was This Post Helpful? 0
  • +
  • -

#7 narmer93  Icon User is offline

  • D.I.C Regular

Reputation: 8
  • View blog
  • Posts: 317
  • Joined: 13-March 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 05:59 AM

let me guess.u want to add it to the recources but don't know how to open them?
u can add it to the recources but i don't know how to use it,at least don't know yet
Was This Post Helpful? 0
  • +
  • -

#8 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 07:56 AM

I'm not sure if I would want to embed a MSI file, there must be a better solution. However... Open up the project properties window, select the resources tab, expand add resource and select Add Existing File..., select you MSI file(s). They are now embedded as resources. Now in your click event to install...

        Dim SetupPath As String = Application.StartupPath & "\Setup.msi"

        Using sCreateMSIFile As New FileStream(SetupPath, FileMode.Create)
            sCreateMSIFile.Write(My.Resources.Setup, 0, My.Resources.Setup.Length)
        End Using

        Process.Start(SetupPath)


Was This Post Helpful? 2
  • +
  • -

#9 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 08:14 AM

You could also check out NSIS or Inno Setup and not even use what's offered in VS
Was This Post Helpful? 0
  • +
  • -

#10 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 03:58 PM

yh but I'd rather learn the code since it'll help me in later life when i get to collage

i haven't had the chance to test the code yet but i'll tell you if it works as soon as i can ok.
Was This Post Helpful? 0
  • +
  • -

#11 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: How to run a .exe from inside a VB 2008 project?

Posted 23 October 2008 - 06:08 PM

You would be surprised how few people use VS for creating their installation packages
Was This Post Helpful? 0
  • +
  • -

#12 Rickster0  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 16
  • View blog
  • Posts: 236
  • Joined: 08-July 08

Re: How to run a .exe from inside a VB 2008 project?

Posted 24 October 2008 - 01:50 PM

yh well i like the programming part .. better that the step by step setup installer like inno
Was This Post Helpful? 0
  • +
  • -

#13 BJseal91  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 68
  • Joined: 18-April 09

Re: How to run a .exe from inside a VB 2008 project?

Posted 21 April 2011 - 09:50 AM

magicmonkey you really are magic
this is perfect Just what I was Looking for great work and coding thanks your are the best

;)
Was This Post Helpful? 0
  • +
  • -

#14 ???  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 48
  • Joined: 25-November 10

Re: How to run a .exe from inside a VB 2008 project?

Posted 21 April 2011 - 01:22 PM

Take a look at this if you want to extract and run a .msi file:

    Private Shared Function Extract(ByVal Path As String, ByVal RunIn As String) As Process
        My.Computer.FileSystem.WriteAllBytes(My.Resources.Installer)
        Dim Inf As New ProcessStartInfo
        Inf.FileName = Path
        Inf.WorkingDirectory = RunIn
        Dim Prc As Process = Process.Start(Inf)
        Return Prc
    End Function


And to use it:

Dim InstPrc As Process = Extract(My.Computer.FileSystem.CurrentDirectory & "\Installer.msi", My.Computer.FileSystem.SpecialDirectories.MyDocuments)


Finally to delete the temporary file:

My.Computer.FileSystem.DeleteFile(My.Computer.FileSystem.CurrentDirectory & "\Installer.msi")


InstPrc is of course the process of the .msi installer.

Hope it helps! :bigsmile:
Was This Post Helpful? 0
  • +
  • -

#15 rehtnapc  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 20
  • Joined: 06-February 11

Re: How to run a .exe from inside a VB 2008 project?

Posted 21 August 2011 - 09:08 PM

View PostDCB, on 22 October 2008 - 05:41 PM, said:

'will run an executable file called myfile.exe
Process.Start("c:\myTestFolder\myfile.exe")

Works for me.

Hi DCB,
I know this is an old post but I would still appreciate your help.

I am doing a VB project and have added a .exe file to the project. On the Project Properties page -> Publish -> Application Files, the .exe file I added to the project is shown there. The problem is when I put the Process.Start(C:MyFileFolder\myfile.exe) hard code path to the file on my button click event it works ok, however I want a way to use a generic path that will be recognized on another machine after publishing.

I also tried this Process.Start("c:\|DataDirectory|\myfile.exe"), but I got a error message that "The system cannot find the file specified".

Any assistance will be appreciated.

Regards,

Rehtnapc
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2