Computing.Net > Forums > Programming > Advanced bat file for copying files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Advanced bat file for copying files

Reply to Message Icon

Name: djanz
Date: September 26, 2008 at 09:39:43 Pacific
OS: DOS
CPU/Ram: 1,8 GHz Pentium 2, 1,0GB
Product: Intel
Comment:

Hi guys..
I'm trying to make a rather advanced batch file..

I have a bootable USB device with DOS 8 and NtfsPro (read/write)..

When booting from the USB device I want it to copy the SAM and SYSTEM file from the Windows OS to the USB.. But doing so in a special way..
Example:
When booting PC1 from USB it should copy SAM and SYSTEM files and save them as SAM1 and SYSTEM1.. Now I go to PC2 and boot from the USB.. this time it should also copy the SAM and SYSTEM files and save them as SAM2 and SYSTEM2 as I dont want the first one to be written over.. I want the bat file to be able to copy from 10 PC's without any files to be overwritten..
How do I do that? .. I have tried to start a bat file:

@echo off

ntfspro.exe

c:

if exist a:\sam9 copy c:\windows\system32\config\sam a:\sam10

if exist a:\sam8 copy c:\windows\system32\config\sam a:\sam9

if exist a:\sam7 copy c:\windows\system32\config\sam a:\sam8

if exist a:\sam6 copy c:\windows\system32\config\sam a:\sam7

if exist a:\sam5 copy c:\windows\system32\config\sam a:\sam6

if exist a:\sam4 copy c:\windows\system32\config\sam a:\sam5

if exist a:\sam3 copy c:\windows\system32\config\sam a:\sam4

if exist a:\sam2 copy c:\windows\system32\config\sam a:\sam3

if exist a:\sam1 copy c:\windows\system32\config\sam a:\sam2

if exist a:\sam copy c:\windows\system32\config\sam a:\sam1 else copy c:\windows\system32\config\sam a:\sam

if exist a:\system9 copy c:\windows\system32\config\system a:\system10

if exist a:\system8 copy c:\windows\system32\config\system a:\system9

if exist a:\system7 copy c:\windows\system32\config\system a:\system8

if exist a:\system6 copy c:\windows\system32\config\system a:\system7

if exist a:\system5 copy c:\windows\system32\config\system a:\system6

if exist a:\system4 copy c:\windows\system32\config\system a:\system5

if exist a:\system3 copy c:\windows\system32\config\system a:\system4

if exist a:\system2 copy c:\windows\system32\config\system a:\system3

if exist a:\system1 copy c:\windows\system32\config\system a:\system2

if exist a:\system copy c:\windows\system32\config\system a:\system1 else copy c:\windows\system32\config\system a:\system

This bat however, will overwrite the first copied SAM and SYSTEM files .. do I really need to set some kind of GOTO command on the end of each line?



Sponsored Link
Ads by Google

Response Number 1
Name: djanz
Date: September 26, 2008 at 09:52:37 Pacific
Reply:

On second thought it would be nice if the
copied SAM file would have a name like SAM-TIME_DATE_YEAR ..

Then one could make a command like:

if exist a:\sam* copy c:\windows\system32\config\sam a:\sam(WHAT EVER THE CMD FOR TIME_DATE_YEAR IS)


0

Response Number 2
Name: Mechanix2Go
Date: September 27, 2008 at 11:37:08 Pacific
Reply:

The bat below will set a var called YMD, using BIOS.

If your NTFS driver allows LFNS you can:

copy SAM SAM%YMD%

====================================
::== YMD8.bat

@echo off > d.d

>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N DAY.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N MONTH.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N YEAR.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N DAT.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Q

debug < d.d > nul
del d.d

dat
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set dat=0%%a
for %%a in ( 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) do if errorlevel %%a set dat=%%a
echo Date %dat%

day
if errorlevel 0 set day=Sunday
if errorlevel 1 set day=Monday
if errorlevel 2 set day=Tuesday
if errorlevel 3 set day=Wednesday
if errorlevel 4 set day=Thursday
if errorlevel 5 set day=Friday
if errorlevel 6 set day=Saturday
echo Day %day%

month
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set month=0%%a
for %%a in ( 10 11 12) do if errorlevel %%a set month=%%a
echo Month %month%

year
if errorlevel 215 set Year=2007
if errorlevel 216 set Year=2008
if errorlevel 217 set Year=2009
if errorlevel 218 set Year=2010
echo Year %Year%

del day.com
del month.com
del year.com
del dat.com

set YMD=%year%%month%%dat%

::== DONE


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Advanced bat file for copying files

bat script for copy lastest file www.computing.net/answers/programming/bat-script-for-copy-lastest-file/16634.html

bat file for deleting www.computing.net/answers/programming/bat-file-for-deleting/11636.html

Bat File Help www.computing.net/answers/programming/bat-file-help-/9414.html