Andre Scutieri
Andre Scutieri

Reputation: 13

How to create a simple installer invoker

Thing is: I have two simple programs (a x86 and a x64 version of the same software) which I download from the Internet. I want to create a CD installer for them.

I only need a small and simple program that "invokes" the setup.exe from the software folder. A simple window with two buttons: "install x86 version" and "install x64 version". Than I could click one of the buttons, the program would call the setup.exe from the right folder, and close itself.

So I could have this structure inside my CD:

./setup.exe
./x64/setup.exe
./x86/setup.exe

Thing is, I don't know how to write this simple software. I have python knowledge, but to install a whole python interpreter just to open a small window with two buttons is quite overkill.

Is there a simple script (in VB, I guess) that could do this for me? I wrote something like this in curses for linux, but I'm no Windows power user.

Thanks a lot in advance!

Upvotes: 0

Views: 113

Answers (1)

Jens
Jens

Reputation: 6375

Create a new WinForms Application in Visual Studio Express and drag the two buttons on the form. Design as you like. Double Click each button to edit the .Click event.

The method to start a new windows process is Process.Start()

Private Sub Button1_Click(sender as Object, e as EventArgs) Handles Button1.Click
    RunAndClose(IO.Path.Combine(Application.StartupPath, "x86", "setup.exe"))
End Sub
Private Sub Button2_Click(sender as Object, e as EventArgs) Handles Button2.Click
    RunAndClose(IO.Path.Combine(Application.StartupPath, "x64", "setup.exe"))
End Sub

Private Sub RunAndClose(filename As String)
  If IO.File.Exists(filename) = False Then
     MessageBox.Show(String.Format("The selected installer {0}{0}{1}{0}{0} could not be found!", vbCrLf, filename), "Installer not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
  Else
     Process.Start(filename)
     Me.Close
  End If
End Sub

You create a sub RunAndClose that actually does the work. You have the filename as a parameter for the sub. Check if the file you want to start exists (IO.File.Exists). If so start it and close the application, if not show an error message.

The Button-Subs use the IO.Path.Combine function. You supply it with a few parts and it builds a path out of it. You want to use it instead of building the string by hand.

Upvotes: 2

Related Questions