Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Autorun CD Menu using Visual Basic

Status
Not open for further replies.

vetaal

IS-IT--Management
May 22, 2006
7
US
I want to create a VB .exe to include in my autorun CD.

Here is what I need:
The .exe should prompt user with a form with 3-4 options, and on clicking the respective options, the user should be see another form with second set of options.

Does anyone have a VBScript for the same?

Here is what I have done/ My issue:

I created a Project in Visual Basic 6.

I created Form1 and added 4 option controls (Frm1Opt1, FrmOpt2, FrmOpt3, Frm1Opt4) on that form.

I created Form2 and added 3 options on that form (Frm2Opt1, Frm2Opt2, Frm2Opt3)

I added a click event for the first option control on form1:

Private Sub Frm1Opt1_Click()
Me.Hide
Form2.Show
End Sub

I have changed the project startup properties to start with Form1.

The problem is that now when I compile and run the program, automatically the click event of the first form-first option runs and I see the Form2 instead of Form 1.
I just do not see Form1.

I had thought that the click event will only run when I select the first option on form 1, but it just runs automatically.

I am not sure how can I change that? I am probably missing something.

Thanks
 
When you assign anywhere in your code:
Code:
Frm1Opt1.Value = True
you will go thru Click event.

Couple of suggestions/my opinions:

Make your options a control array, this way you will have one Click event for all options, which in most part would be the same anyway. Why repeat all the code in each Click event?

Option buttons themselves should not cause any action (in my opinion). Place a command button, and after the option is chosen, command button will have the action needed for that choice.

---- Andy
 
Thanks Andy.

I am relatively new to VB. I guess creating a control menu will be a good idea alongwith a cmd button for OK and Exit

How do I create a control array? Is it a feature in the menus or the toolbox?

My concept is pretty simple, we send out these Cds to our field people. Normally we just used to include the .msi and create an autorun.inf, but now we want the user to see this menu, so that they feel good about doing it themselves, rather than forcing it on them.

Eg. As soon as the Cd is entered user sees this menu:
- Install My Applications
- Exit Menu
- If any option is Selected, following screen shows:
Install Visio SP3
Install Adobe Reader
Exit Menu

and so on.
 
OK, a little basics of VB:

On an empty Form, if you place an option button, and double click on it, you will go to Click event that will look like this:

Code:
Private Sub Option1_Click()

End Sub

Delete this code, please.

Copy the option button, and then paste it to the Form.
VB will ask you if you want to create a control array.
If you say 'YES', you will have 2 option buttons: one with index of 0 and another with index of 1

Double click on any of them and you will see this code for a click event:
Code:
Private Sub Option1_Click(Index As Integer)

End Sub

Notice Index As Integer

Usually you would code something like:
Code:
Private Sub Option1_Click(Index As Integer)

Select Case Index
    Case 0   'option 0 is chosen
         Do you code for 0 here
    Case 1   'option 1 is chosen
         another piece of code for option 1

    etc.....
End Select

End Sub

Have fun.

---- Andy
 
Opps, I forgot to add:

Code for an OK command button :
Code:
Private Sub cmdOK_Click()

Select Case True
   Case Option1(0).Value
        Call Install_Visio_SP3
   Case Option1(1).Value
        Call Install_Adobe_Reader
End Sub

End Sub

---- Andy
 

Wonderful Andy!
I will upload the code once I have it up and running!

Thanks
 
Andy,

To make a call to install Visio
- I created a sub-function:

Private sub installVisio()

End sub

Now, to call the Visio installer - do I just enter:
Execute "visio2003.msi"
or run "visio2003.msi"

I am getting a sub not defined on this command on trying to compile the program.

How do I call an external .exe or .msi?

Thanks
 
I tried adding this in the code:


Private sub installVisio()
shell("visio2003.exe")
End sub

above comes with a runtime error of path not found or file not found

If I enter shell("D:\visio2003.exe") it works
but I cannot hard code the path coz the user may have a different drive mapped for the CD or DVD drive.

I even tried creating a dir called apps and tried
shell("..\apps\visio2003.exe") but it did not work.

Any help is appreciated..also what if the app is an msi and not an .exe?

Thanks
 
If the exe will be at the same place as your VB EXE, you can use
Code:
Shell(App.Path & "\visio2003.exe")

To code and check if this will work for you at design time, you need to have visio2003.exe at the same location as your VB's vbp

As for msi, I would try the same approach.

Have fun

---- Andy

 
Andy,

The call to exe works, but the call to a msi comes with some error.

Quick question - all the apps get executed in a minimize mode. I have to click on these apps on the taskbar to maximize them.

How do I open them in maximize mode?

Thanks
 
No issues.

I was not making a call to a windows installer .EXE.

I was calling a standalone executable called WiLogUtl.exe (a utility to parse log files). The utility was opening in minimized mode.

As soon as I changed my .EXE to a different installer program, the installation started in normal mode.

Any thoughts about how to directly call a .msi though?

Thanks Andy
 
Try:
Code:
Dim lngVal As Long

lngVal = Shell(App.Path & "\visio2003.exe", _
[b]vbNormalFocus[/b])

msi - I don't know what it is.
Do you need to run something else to execute this msi file?

Try:
Code:
lngMaVal = Shell("WiLogUtl.exe " & MyFile.msi, _
vbNormalFocus)

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top