Link to home
Start Free TrialLog in
Avatar of steambyte
steambyte

asked on

RunOnce registry entry

I have an installation program that needs to install DCOM98. This needs a reboot before Mdac_typ.exe can be installed.

I think there is a registry entry called runonce that can be set to run a program once only on restart.

1. Can I use this to continue with my installation after installing DCOM98. Madc will not install unless DCOM98 is there.
2. How can I find the name of my installation program that will be called by Runonce. The installation maybe on CDROM
3. How safe is it?


I am using Wise Ver4 that can force a reboot and change and check registry entries.
ASKER CERTIFIED SOLUTION
Avatar of KDivad
KDivad

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KDivad
KDivad

Here are the API's and constants that can be used to set or check the value:
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" Alias "RegCloseKey" (ByVal hKey As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Public Const HKEY_CURRENT_USER = &H80000001
Public Const REG_SZ = 1

And some code:
Dim hReg As Long
RetVal = RegCreateKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\RunOnce", hReg)
RetVal = RegSetValueEx(hReg, "InstallApp", 0, REG_SZ, Full_Path_To_App, Len(Full_Path_To_App))
RetVal = RegCloseKey(hReg)

RegOpenKey can be used instead of RegCreateKey if you are sure the key is there. RegCreateKey works the same as RegOpenKey if the key is already there.
The parameter I've passed as "InstallApp" can be valid string.
Oops, I meant:

The parameter I've passed as "InstallApp" can be ANY valid string.
1. Yes, I would say add mdac's install app to this key and let it continue as normal.
2. Use the RegQueryValueEx string that I provided with the same types of parameters as the RegSetValueEx used in the code.
3. Perfectly.

Umm, Use this RegQueryValueEx declare instead of the other one. You will be working with strings, so a modification is necesary:

Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Avatar of steambyte

ASKER

Not exactly what I asked but offers a good alternative. I will use the regkeys in Wise and install the MDAC_TYP in a temporary subdirectory which I can create as a sub of my main app dir
Must have misread your question a bit, but I am glad it helped you anyway.
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange