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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a batch file during boot 1

Status
Not open for further replies.

AP81

Programmer
Apr 11, 2003
740
AU
I don't know if this is possible, but I would like to run a batch file during the windows boot process.

It is not possible to run after windows has loaded as these are all locked once windows is running.

Is this possible?


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
It is not possible to run after windows has loaded as these are all locked once windows is running
What "these" are you referring to?

What is it, precisely that you are trying to accomplish, in detail & not that you want to run a batch file.

rvnguy
"I know everything..I just can't remember it all
 
Sorry, in trying to simplify things I have also complicated them.

I am trying to back up some Windows registry files. I have more than 1500 machines to do this on, so that is why I am trying to automate it.

This is my batch file:
Code:
copy c:\windows\system32\config\system c:\windows\backup\system
copy c:\windows\system32\config\security c:\windows\backup\security 
copy c:\windows\system32\config\default c:\windows\backup\default 
copy c:\windows\system32\config\sam c:\windows\backup\SAM 
copy c:\windows\system32\config\software c:\windows\backup\software

All the above files are locked when Windows is running.

The only way I have been able to successfully do it is to boot up to the recovery console and run the batch file (batch backup.bat). This would be uneconomical and hard to get 1500 different users to perform a manual backup over the phone.

Ideally I would like to be able to write an app which can tell windows to run the batch file on next boot, however getting windows to run a batch file on boot is my only hurdle.

Can you see my dilemma?

Any help is appreciated.


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
MS said:
System File Checker
System File Checker (Sfc.exe) is a command-line tool that examines protected system files on your computer and restores the correct versions by using backups stored in the Dllcache Protected files include those with .sys, .dll, .exe, .ttf, .fon, and .ocx file-name extensions.
Many protected files are already backed up by XP. Compare your list to those in Dllcache.
I assume that you are wanting to back up locally, and might not have been aware that XP does much of this already. also the Hive or SAM files are part of system restore.

System Restore Frequently Asked Questions (FAQ)

You might find that you do not need to do this

Post back with what you determine

rvnguy
"I know everything..I just can't remember it all
 
This utility reportedly will copy even locked files.
You can choose which files to backup.
This should be able to be scripted to run after XP load & might do the job if XP is not already getting all the files you want.

Using Windows XP Backup Utility


rvnguy
"I know everything..I just can't remember it all
 
None of the files in my batch file are backed up to c:\windows\system32\dllcache.

These are the only files I am interested in. If this was the case I think MS would have recommended this as the best way to fix this problem, however they recommend doing backups using the recovery console.

Thanks for you input anyway.
Adam


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
The Windows backup utility is pretty good, however it backs up all files into a single .bkf file. The only way you can restore them is by using the backup utility to perform a restore.

Not much help if your system is not bootable and/or cannot be run from a recovery console.

Anyway, thanks again for trying


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Take a look at ERUNT. You should be able to work something out with that tool.

Jeff
[purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day

"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me
 
Not much help if your system is not bootable
Exactly how do you think having a true copy of the files provides as better solution if the system won't boot?

rvnguy
"I know everything..I just can't remember it all
 
Exactly how do you think having a true copy of the files provides as better solution if the system won't boot?

Typical scenario:
user turns on PC. System boots and says:
'The following file is missing of corrupt: c:\windows\system32\config\system'

The only way you can fix this is by with a backed up copy of your original file, or by a long drawn out process of copying files from c:\windows\repair, then doing a system restore then other various tasks. Trust me, I have spent a lot of time investigating this ...


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
AP81,

To answer your original question... you may/should be able to use a startup script.

1) Open the Group Policy Editor (Start > Run > enter 'gpedit.msc'.)
2) Expand 'Computer Configuration'.
3) Expand 'Windows Settings'.
4) Select 'Scripts (Startup/Shutdown)'.
5) Double-click on 'Startup' in right-hand pane.
6) Click on the 'Add' button.
7) Click on the 'Browse' button.
8) Navigate to your batch file, select it and OK your way out of the Editor.
9) Close the Editor.

I haven't used this for startup scripts but do use it all the time for shutdown scripts to clean out temporary files, etc.

Hope this helps...
 
go to c: prompt
edit autoexec.bat
put copy commands in the file.
example:
copy x:\myfolder\*.dll y:\mybkfolder\*.dll
that's all you need to do.

when windows boots up, all the commands in this file are executed.
 
go to c: prompt
edit autoexec.bat
put copy commands in the file.
example:
copy x:\myfolder\*.dll y:\mybkfolder\*.dll
that's all you need to do.

when windows boots up, all the commands in this file are executed.
you can also executed a vb script.
let me know, and i'll post one for you.
 
Thanks for your help.

Alibradi, if it was as easy as that I would have already done it. All the files I am trying to copy are locked when windows is running.
On Win98 I wrote a bootloader with Assembler and DOS that allows to do backup and restores from a boot menu. As for XP, the files I need to backup are fully locked when Windows is running.

MasterRacker, thank you for suggesting Erunt. With this I can copy locked files. I managed to copy some of the erunt files to the c:\windows\system32 directory and can run a silent backup via the command line. Thanks Again.


------------------------------------
There's no place like 127.0.0.1
------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top