Hi Mark
I found this code at vbacceleratot, has many good things in it, take a
look at it.....
http://vbaccelerator.com/codelib/inireg/regmisc1.zip
Also, in my case I'm running W2kAS, At the point of entry of runonce
I think a lot of background process are already starting up I found
through a search looks like 7 may be more advantages to use as MS
would add/remove programs I would think when nothing of there
system(even though I'm not going to install anything)were not being
held, tell me what you think
the following was found at
Http://support.microsoft.com/support/kb/articles/Q137/3/67.asp
1. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
2. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
3.HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce
4. HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
5. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
RunServices
6. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
RunServicesOnce
------------------------
7. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\
RunOnce\Setup
------------------------
MORE INFORMATION
Keys 1-4 are run each time a new user logs in.
Keys 5-6 are run in the background when the logon dialog box first
appears, or at this stage of the boot process if there is no logon.
These keys are for background services such as remote registry service
and are run only once per boot.
---------------
Key 7 is run as part of Setup's first-boot activities, or after you
use the Add/Remove Programs Wizard.
----------------
Under each of these keys is a series of values. The values are used to
allow multiple sub-entries to exist without overwriting one another.
The data value for a value is a command line. By default, Run keys are
ignored in Safe mode. For keys 3-4, the value name can be prefixed
with an exclamation point to defer deletion of the value until after
the command has been completed.
For keys 3, 4, and 6, the value is deleted before the command line is
run unless overridden as noted above. As a result, if a RunOnce
operation fails to run properly, the component that failed will not be
asked to run again the next time you start the computer.
-------------------
Key 7 is used only by Setup. This key displays the progress dialog box
as the keys are run one at a time. For key 7, the name of the value is
the name that is displayed in the dialog box.
-------------------
This is more then I ever wanted to know on this topic :)
Jerry
On Wed, 27 Dec 2000 17:39:20 -0000, "Marcus Chambers"
Quote:
>Hi Jerry.
>X-mas was very loud as I have three children who receive ever noisier gifts
>every year!!
>First of all I must point out that I am not an expert, and my reply is only
>how I understand it, therefore, I cannot reply with sound facts. I have had
>no training in VB, every thing I know is from trial and error. When I want
>VB to do something new I just keep trying until it does what I want. I am
>happy to post code which I know from past experience will work, however, I
>don't want to be chastised by anyone else out there if I tell you something
>which is wrong.
>Maybe there is an expert out there who would be kind enough to correct my
>answer if it is wrong.
>Anyway I will try to answer your question.
>Yes there is more than one RunOnce in the Windows Registry. I believe this
>is because if a system is used by more than one person, and you only want
>the entry to effect the person who is logged on at that time, you would
>place it into HKEY_CURRENT_USER. If the OS supports individual Profiles such
>as Windows NT, each user has a separate HKEY_CURRENT_USER section for the
>Registry, but all users share some parts of it including HKEY_LOCAL_MACHINE.
>If it is a change which would effect all users then you would place it in
>HKEY_LOCAL_MACHINE as this is used by all User Profiles.
>If your application is running over a network, or on a machine with multiple
>users then this method of placing an entry into RunOnce may not be the best
>method to use. If this is the case you must restructure your Application.
>Also, I do not know what effect the use of entering into RunOnce if
>something else has made an entry. As you probably know, there are many
>instances where a file is run after a reboot.
>It would probably be safer to check for any entries first, before placing an
>entry of you own. this would be relatively easy, and I would be happy to
>work it out and send you the code for this if you require it.
>It may be worth doing some testing, by manually making two entries into
>RunOnce and observing the effect during reboot, however, it is very easy to
>destroy a system if you damage the registry, so I would suggest you always
>prepare for the worst before you use the registry, Back up all data incase
>you have to format your drive and re-install everything. Always better to be
>safe than sorry.
>As to your question regarding chkdsk I would say yes, it is most likely to
>place it into the RunOnce in HKEY_LOCAL_MACHINE.
>Hope this helps you.
>Mark
>> Hi Mark hope X-mas was good :)
>> I've tried the code and it works great , just wondering that point of
>> entry will some system files be still in use at that time.....I read
>> there are about 5 different runonce entry points are so... for
>> different reason
>> My program leaves it to the user what he wants to backup and
>> saves his selection, (path) to a file to be run on a schedule. What
>> I'm trying to do is open the file for shared access if it cannot it
>> is written to the copyheld.bat file, otherwise its copied at that
>> point for backup
>> Since the user could select a directory of an app or even the whole
>> drive were his system may reside. will that entry point for runonce
>> still hold some system files....
>> I wonder a lot :)
>> Wondering, when you run chkdsk on the system disk it says it cannot
>> run it at that time would you like to run it on the next boot of
>> system, is this the same point of entry
>> Thanks again for all your time patience Mark , thanks Tony for
>> posting code
>> Jerry
>> On Tue, 26 Dec 2000 14:08:42 -0000, "Marcus Chambers"
>> >Hi jerry
>> >I see that someone else has replied with similar code but I will send it
>> >anyway.
>> >try adding the following:
>> >Dim KeyPath As String
>> >Dim AppName As String
>> >Dim Value As String
>> >Value = "C:\Copyheld.bat"
>> >AppName = "YourAppsName"
>> >KeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\" &
>> >AppName
>> >Set objRegWrite = CreateObject("WScript.Shell")
>> >objRegWrite.RegWrite KeyPath, Value
>> >Note: this code is dependant on the file "WScript.exe" which can be
>found
>> >in the System32 folder but I don't know if this file is a installed as
>part
>> >of windows. If it isn't a windows file you will have problems if
>> >distributing your app on other machines. If you need to you could add
>the
>> >file to your distribution disk's when you use P&D Wizard.
>> >Mark
>> >> Hi Mark what I did I took the winseek example that comes on the
>> >> visual basic cd and modified it. to go through the directories I
>> >> selected to copy files over to another disk, before copying each file
>> >> I check to see if any of the files are being held, if so I write it to
>> >> a file , hopefully to copy during a reboot by calling the copyheld.bat
>> >> I created... I was wondering if there was a simple way to write the
>> >> name of that file whicj will reside on the root of my c drive to the
>> >> runonce key. I looked at the examples in the VB books online and it
>> >> seems to suggest that you can only write , update reg entries for your
>> >> app only using SaveSetting, not exactly what I'm trying to do
>> >> thanks again
>> >> Jerry Cohen
>> >> On Sat, 23 Dec 2000 16:48:03 -0000, "Marcus Chambers"
>> >> >You need to make an entry into the following registry location giving
>the
>> >> >path of the file which you wish to run only once after a ReBoot
>> >> >HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
>> >> >On ReBoot Windows will run you file then automatically remove the
>entry
>> >from
>> >> >the registry.
>> >> >Hope this helps.
>> >> >Mark
>> >> >> Hi I know how to cause VB to reboot NT4 and W2k what I'm trying to
>do
>> >> >> is during the reboot execute a bat file in order to backup some
>files
>> >> >> that are held in the OS.
>> >> >> Thanks
>> >> >> Jerry