HELP WITH AUTORUN.INF file to start a VB setup

Hi Friends,
I have a installation program that installs MSDE and I need to restart the computer upon successfully installing MSDE.But the problem is the "AUTORUN.INF" file does not start with any program on computer restart.
Is there any parameter I need to add in the .INF so that it can detect a restart and appropriately load setup/.exe or entry in registry so that the computer can start a program on restart?

Thanks in advance.
SK

[479 byte] By [VB_Programmer] at [2007-12-16]
# 1
Add the following registry key with your program:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce

Look at http://support.microsoft.com/?kbid=179365 for more information.

DanVallejo at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Thanks for the information.Can you let me know what entries I need to add to the Autorun.inf file?
VB_Programmer at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
I think what Dan was getting at, is during the installation of your program, create a registry key in the location he specified. Usually it's a RegSZ data type, the name is the name of your app. and the data value is the path's exe's location (and args).

So, all you have to do, is install the program, and when the computer reboots, it'll notice there's something in the 'runonce' section of your computer, it will run that file, (your application) and remove it from the list.
If you asking about the format of a autorun.inf, it looks like this...
[autorun]
open=Setup\autorun.exe
icon=Setup\F4.ico

(: note, you have to change the paths :)

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Thanks for the information.My Autorun.inf file looks like this:
[autorun]
OPEN=Installation_Wizard.exe /AUTORUN
ICON=Installation_Wizard.exe,1

shell\configure=&Configure...
shell\configure\command=Installation_Wizard.exe

shell\install=&Install...
shell\install\command=Installation_Wizard.exe
So you are telling me to add a key,value entry thru the program at HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce location in the registry.This can be accomplished.I want the program that is on my CD to run(Installation_Wizard.exe).How do I specify that in my Autorun.inf file?

Any help will be appreciated.

VB_Programmer at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 5
Adding a key entry to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce will only make that program run.

You can make a small app that either launches the installer, or the post-installer code depending on the arguments past to it.

example...
for the cd, edit the autorun to start the launcher, which will start Installation_Wizard.exe if the 'post-reboot' argument is not specified.
[autorun]
OPEN=Launcher.exe /AUTORUN
ICON=Installation_Wizard.exe,1

That way, when you put in the cd, it'll see Launcher.exe /AUTORUN, and start the Installation_Wizard.exe program. During install, add a key for HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce\ with the values of "Launcher.exe /post_install" when computer reboots, the cd's launcher will run the other post install code.

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 6

Thanks for the information, that really helped.How do we specify in the value that was added to the registry that the file is to be picked up from my CD?.It looks at my local machine and tells such a file is not found.Any help will be very much appreciated.

Thanks,
SK

VB_Programmer at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 7

This is a Console application i made for example.
Note: That in the assemblies of the project, i had to put the application's exe name as the description because it's just easier to retrieve that way. (My.Application.Info.Description)



Imports Microsoft.Win32
Module Module1

Sub Main()
If My.Application.CommandLineArgs.Count <> 0 Then
If My.Application.CommandLineArgs(0) = "-PostInstall" Then
INSERT POST_INSTALLER PROGRAM HERE
End If
Else
Dim regKey As RegistryKey
regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,
My.Computer.Name).OpenSubKey("Software\Microsoft\Windows\CurrentVersion\RunOnce", True)
regKey.SetValue(
My.Application.Info.ProductName & " Setup", "" & My.Application.Info.DirectoryPath() & My.Application.Info.Description & "" & " -PostInstall")
Shell(
My.Application.Info.DirectoryPath() & "Install_Wizard.exe", AppWinStyle.NormalFocus, False)
End If
End Sub

End Module

If you set this type of program as your auto-run program from the CD, it'll check the arguments passed to it. If it has "-PostInstall", then it will run the program that you choose to put in the post install code section. Otherwise, it runs the default install wizard.

Note, that in this example, the program creates the registry key then runs the setup wizard. It would be better to have the installation program do this for you, so if they cancel it doesn't try to do post code.

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 8
Thanks for all your help.That was really great!!.
VB_Programmer at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 9

Now that I saw ur Shell command I am using ShellExecute API to run my program.Is it possible to detect an installation that was initiated by the Shell Execute when it is complete using the API.This will help me a lot in my installation procedure.
Thanks a lot.
SK.

VB_Programmer at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 10
The only way you'll be able to tell what program launched another is by the command line arguements passed to it.

Atleast, i'm pretty sure.

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...