Does anyone know howto cause a bat file to be excuted during reboot from vb app 
Author Message
 Does anyone know howto cause a bat file to be excuted during reboot from vb app

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



Wed, 11 Jun 2003 22:38:48 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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


Quote:

> 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



Thu, 12 Jun 2003 00:48:03 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
This is the first time I've seen this group and posted a message here
This morning after finding the group I thought I'd   post a message on
something that has been driving me crazy for awhile, I can't believe
how quick the response, thank you. being new to VB do you have an
example of updating the reg's  RunOnce and again think you

sincerely
Jerry Cohen

On Sat, 23 Dec 2000 16:48:03 -0000, "Marcus Chambers"

Quote:

>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



Thu, 12 Jun 2003 03:15:23 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
There are a few methods to enter a value into the Registry.
The simplest method I know of, which will be ok for you if you want your App
to make the entry only when it is installed so that your BAT file will run
when the System ReBoots is as follows:-

Open Regedit.exe (found in your windows/WinNT Folder).
Browse to the RunOnce location specified in my earlier response.
With the RunOnce Key Selected, Right Click it and Select "New" then "String
Value".
Name the String Value (The Name of your App or something)
After you have Named it Right Click on it and Select "Modify"
Type in the Path of the BAT file you want to run as the "Value Data"

With your New Registry Entry Selected go to the "Registry" DropDown Menu and
Select "Export Registry File"

Name the file (MyRegEntry or something) and save it to the location of your
VB Project Files.

Once Saved right click on the entry you made and select DELETE (you don't
want your PC to run the BAT file when you ReBoot!).

When you run the Package and Deployment Wizard and it gets to the Included
Files Section Click on the "Add" button.

Click on the "Files of Type" menu and select Registry Files. Then browse to
the Reg File you saved earlier.
When you click Next it will open a Registry Information window. Leave it
with the default settings and click Next and finish running the P&D Wizard
as normal.

When you Application is installed it will place the Registration Entry
automatically for you.

Hope this works.

Mark
Ps.  e-mail me and let me know how you get on at

thank you.


Quote:
> This is the first time I've seen this group and posted a message here
> This morning after finding the group I thought I'd   post a message on
> something that has been driving me crazy for awhile, I can't believe
> how quick the response, thank you. being new to VB do you have an
> example of updating the reg's  RunOnce and again think you

> sincerely
> 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



Thu, 12 Jun 2003 07:30:41 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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"

Quote:

>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



Thu, 12 Jun 2003 09:54:01 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
Hi Jerry
search MSDN Library for RegCreateKey for method.
I will send you some code after Christmas if you haven't managed to work it
out, but for the moment my wife has put a PC Ban on me until after
Christmas.

Mark


Quote:
> 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



Thu, 12 Jun 2003 16:54:47 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app

I don't know about everyone else but managing the Registry in VB
has always been somewhat of a challenge until you build your set
of portable modules to add to your new projects.

I stumbled accross an article in MSDN on using the VBScript
control to manage the registry. Basically, just a few lines of
code. You add the VBScript Control to your project, drop it on
a form and ...

Set objWSH = CreateObject("WScript.Shell")
objWSH.RegDelete "HKCU\" & RegPath

That's it, also methods for RegWrite and RegRead. Not for everyone but
it is a hell of a lot messier than the API calls for the simple stuff.

Set objWSH = CreateObject("WScript.Shell")
objWSH.RegWrite "HKCU\ScriptEngine\Value", "Some string value"
objWSH.RegWrite "HKCU\ScriptEngine\Key\", 1 ,"REG_DWORD"


Quote:
> 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



Fri, 13 Jun 2003 23:03:47 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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


Quote:
> 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



Sat, 14 Jun 2003 22:08:42 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
Sorry Jerry
Ignore the Note at the bottom about WScript.exe. I have just been playing
with it and so I related it to the code I just sent you.


Sat, 14 Jun 2003 22:16:18 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
Hi Jerry
The API method is as follows

Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1   ' Unicode nul terminated string
Const SUB_KEY = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"

Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA"
(ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal
lpData As String, ByVal cbData As Long) As Long

Private Sub UpdateRunOnce(Value As String)

    RegSetValue HKEY_LOCAL_MACHINE, SUB_KEY, REG_SZ, Value, 255

End Sub

Place your Bat file from your app with the following:

    UpdateRunOnce "C:\Copyheld.bat"

Hope this helps. Let me know how you get on.

Mark


Quote:

> 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



Sun, 15 Jun 2003 03:26:42 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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"

Quote:

>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



Sun, 15 Jun 2003 23:49:12 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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


Quote:
> 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



Mon, 16 Jun 2003 01:39:20 GMT  
 Does anyone know howto cause a bat file to be excuted during reboot from vb app
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



Mon, 16 Jun 2003 04:29:38 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Anyone Know how to get a VB prog to reboot Win95 and NT

2. Coolbar causes crash - what am I doing wrong

3. When is shelled .BAT file done?

4. Does anyone really know the cause of this?

5. AnyOne knows How It can Be Done?

6. AnyOne knows How It can Be Done?

7. Does anyone know how to start a .exe file in VB Script

8. autoexec.bat and .bat files

9. Does anyone know how to register a file type in vb 4.0

10. Placing APP.EXE file in the AutoExec.BAT

11. Binary files - what am I doing wrong?

12. Launching app running .bat file on remote computer?

 

 
Powered by phpBB® Forum Software