|
原帖由 123 于 2007-10-29 05:20 PM 发表
可以考虑,不过如果硬盘文件比较多会不会很慢啊?
这是深度 一健自动搜索GHO镜像的的批处理:
@echo off
set searchfolder=
set object=
set object=%1
for %%a in (r R) do if %2#==-%%a# set searchfolder=Yes
echo 搜索范围:所有存在驱动器的根目录和一级目录>%temp%\me.bak
echo 搜索对象:%1>>%temp%\me.bak
echo 搜索路径:>>%temp%\me.bak
echo.>>%temp%\me.bak
echo.>>%temp%\me.bak
echo.>>%temp%\me.bak
echo 搜索结果:>>%temp%\me.bak
call vtm /T %temp%\me.bak %temp%\menu.bak
wbat fill24,10(1,62)(white on +black) " "
wbat fill16,10(7,62)(white on +black) " " !text17,10@%temp%\menu.bak
wbat text21,16(1,50)(+white on black) "[ ]"
for %%a in (folder result) do if exist %temp%\%%a.txt del %temp%\%%a.txt
drvtypes /d>%temp%\drv.txt
type %temp%\drv.txt|find /v "A:"|find /v "B:"|find /v "%RAMDRIVE%" >%temp%\drv.txt
strings linage=linesize %temp%\drv.txt
strings drv=read %temp%\drv.txt,1
if %drv%#==# goto end
strings linage=add %linage%,1
set number=0
:cycle
if %number%#==%linage%# goto next
strings number=add %number%,1
strings drv=read %temp%\drv.txt,%number%
if %drv%#==# goto cycle
dready %drv% /w |if errorlevel 2 goto cycle
echo %drv%>>%temp%\folder.txt
if %searchfolder%#==# goto cycle
dir "%drv%" /ad/b>%temp%\path.txt
strings linepath=read %temp%\path.txt,1
if %linepath%#==# goto cycle
strings linepath=linesize %temp%\path.txt
strings linepath=add %linepath%,1
set pathnum=0
:pcycle
if %pathnum%#==%linepath%# goto cycle
strings pathnum=add %pathnum%,1
strings folder=read %temp%\path.txt,%pathnum%
if %folder%#==# goto pcycle
echo %drv%\%folder%>>%temp%\folder.txt
goto pcycle
:next
for %%a in (searchfolder linage drv number linepath pathnum folder) do set %%a=
strings linage=linesize %temp%\folder.txt
strings linage=add %linage%,1
calc387 49 / %linage%>%temp%\norm.txt
strings norm=read %temp%\norm.txt,1
set guage=1
set number=0
:search
if %number%#==%linage%# goto end
strings number=add %number%,1
strings location=read %temp%\folder.txt,%number%
if %location%#==# goto search
dir "%location%\%object%" /a/b >%temp%\file.txt
strings filenum=read %temp%\file.txt,1
if %filenum%#==# goto guage
strings filenum=linesize %temp%\file.txt
strings filenum=add %filenum%,1
set num=0
:file
if %num%#==%filenum%# goto guage
strings num=add %num%,1
strings file=read %temp%\file.txt,%num%
if %file%#==# goto file
set wz=0
set filesize=
set filedate=
strings filesize=filesize %location%\%file%|if errorlevel 1 goto result
strings filedate=filedate %location%\%file%>nul
strings filesize=div %filesize%,1024
if %filesize%#==0# set filesize=1
strings length=length %filesize%
set div=%filesize%
:div
strings div=div %div%,1024
if not %div%#==0# strings wz=add %wz%,1
if not %div%#==0# goto div
strings wz=add %length%,%wz%
strings wz=sub 38,%wz%
strings filesize=addcommas %filesize%
set filesize=%filesize%KB
:result
set name=%location%\%file%
if not %wz%#==0# strings name=left %name%,%wz%
echo %name% %filesize% %filedate%>>%temp%\result.txt
wbat fill24,10(1,62)(white on +black) " " !text24,15 "%name% %filesize% %filedate%"
goto file
:guage
calc387 %guage% + %norm%>%temp%\norm.txt
strings guage=read %temp%\norm.txt,1
strings _dot=filename %guage%
calc387 %guage% * 2 - 1>%temp%\norm.txt
strings percent=read %temp%\norm.txt,1
strings percent=filename %percent%
wbat fill19,26(1,40)(white on +black) " " !text19,26(1,40) "%location%"
wbat fill21,16(1,%_dot%)(white on blue) !text21,39(1,2) "%percent%%%"
goto search
:end
wbat fill21,16(1,50)(white on blue) !text21,39(1,2) "100%%"
for %%a in (gho GHO iso ISO) do if %1#==*.%%a# if exist %temp%\result.txt copy %temp%\result.txt %temp%\%%a.ini /y >nul
for %%a in (drv folder path file norm) do if exist %temp%\%%a.txt del %temp%\%%a.txt
for %%a in (menu me) do if exist %temp%\%%a.bak del %temp%\%%a.bak
for %%a in (linage norm guage number location num file filenum object _dot percent filesize filedate wz length div name) do set %%a=
还原时的批处理:
@echo off
cls
set gpos=4
if exist %temp%\hdd.ini wbat [email=text@%temp%\hdd.ini]text@%temp%\hdd.ini[/email]
if exist %temp%\gho.ini wbat [email=text25@%temp%\gho.ini]text25@%temp%\gho.ini[/email]
if exist %temp%\hdd.ini goto usable
call vtm /P 硬盘没有可用空间。 %temp%\menu.bak
wbat list @%temp%\menu.bak
goto end
:usable
if exist %temp%\gho.ini goto next
:Nogho
call vtm /P 没有发现Ghost映像文件。 %temp%\menu.bak
wbat list @%temp%\menu.bak
goto end
:next
type %temp%\hdd.ini|find "1:"|find "Act" >%temp%\hdd.tmp
if not errorlevel 1 goto active
set actsign=1:1
goto ghofile
:active
strings active=read %temp%\hdd.tmp,1
strings actsign=left %active%,13
strings actsign=right %actsign%,4
for %%a in (%actsign%) do set actsign=%%a
:ghofile
strings ghonum=linesize %temp%\gho.ini
type %temp%\gho.ini|find /i "SYSBACK" >%temp%\gho.tmp
if errorlevel 1 goto default
strings num=linesize %temp%\gho.tmp
if not %num%#==0# goto default
strings gho=read %temp%\gho.tmp,1
if not %gho%#==# set wcb1=0
if not %gho%#==# goto 盘符转换
:default
if %ghonum%#==0# strings gho=read %temp%\gho.ini,1
if %ghonum%#==0# if %gho%#==# goto Nogho
if %ghonum%#==0# goto 盘符转换
:映像选择
echo :yxxz "请选择一个Ghost镜像文件,作为还原点:(取消按Esc键)" [x]>%temp%\me.bak
call vtm /T %temp%\me.bak %temp%\menu.bak
type %temp%\gho.ini>>%temp%\menu.bak
call w.bat [email=list@%temp%\menu.bak:yxxz]list@%temp%\menu.bak:yxxz[/email]
if errorlevel 100 goto end
if %wbat%#==# goto 映像选择
set gho=%wbat%
:盘符转换
echo @echo off>%temp%\part.bat
echo set ghofile=%%1>>%temp%\part.bat
call %temp%\part.bat %gho%
for %%a in (%gho%) do set ghodate=%%a
strings ghoy=right %ghodate%,4
strings ghom=left %ghodate%,2
strings ghodate=left %ghodate%,5
strings ghodate=right %ghodate%,2
strings ghodrv=left %ghofile%,2
if %nofat%#==No# goto Restore
if not exist %temp%\nofatdrv.ini goto end
type %temp%\nofatdrv.ini|find /i "%ghodrv%" >nul
if errorlevel 1 goto Restore
type %temp%\hdd.ini|find /i "%ghodrv%" >%temp%\gho.tmp
strings ghopart=read %temp%\gho.tmp,1
strings ghosign=left %ghopart%,13
strings ghosign=right %ghosign%,4
for %%a in (%ghosign%) do set ghosign=%%a
strings ghoname=length %ghofile%
strings ghoname=sub %ghoname%,2
strings ghoname=right %ghofile%,%ghoname%
set ghofile=%ghosign%:%ghoname%
:Restore
set xz= 有多个Ghost映像存在 [按此重选映像 (&C)))]
if %ghonum%#==0# set xz=.
if %ghonum%#==0# set gpos=3
if %wcb1%#==# set wcb1=1
echo :Restore "还原系统最后确认!" [x]>%temp%\me.bak
echo @将%actsign%区还原到%ghoy%年%ghom%月%ghodate%日备份前状态@>>%temp%\me.bak
echo Ghost映像:%ghofile%>>%temp%\me.bak
echo%xz%>>%temp%\me.bak
echo.>>%temp%\me.bak
echo 还原到(激活)%actsign%区 [按此重选 (&D)))]>>%temp%\me.bak
echo.>>%temp%\me.bak
echo [! 在还原前,先检测Ghost映像完整性]>>%temp%\me.bak
echo ==========================================>>%temp%\me.bak
echo [ 开始还原 (&A)] [ 返回 (&E)]>>%temp%\me.bak
echo :>>%temp%\me.bak
call vtm /T %temp%\me.bak %temp%\menu.bak
call w.bat fix box12 @%temp%\menu.bak:Restore #%gpos%
set gpos=%?%
if %wbat%#==E# goto end
if %wbat%#==C# goto 重选映像
if %wbat%#==D# goto 还原选择
:ghost
call ifs -c
if exist %ramdrive%\quit.bat call quit.bat
if exist ghosterr.txt del ghosterr.txt
set ghoerr=
if %wcb1%#==1# ghost -chkimg,%ghofile% -sure -fx
if %wcb1%#==1# call 错误报告
if not %ghoerr%#==# goto end
ghost -clone,mode=pload,src=%ghofile%:1,dst=%actsign% -sure -fx
call 错误报告 还原系统
goto end
:重选映像
echo :yxxz "请选择一个Ghost镜像文件,作为还原点:(取消按Esc键)" [x]>%temp%\me.bak
call vtm /T %temp%\me.bak %temp%\menu.bak
type %temp%\gho.ini>>%temp%\menu.bak
call w.bat [email=list16@%temp%\menu.bak:yxxz]list16@%temp%\menu.bak:yxxz[/email]
if errorlevel 100 goto Restore
if %wbat%#==# goto 重选映像
set wcb1=0
echo %wbat%|find /i "SYSBACK"|if errorlevel 1 set wcb1=1
set gho=%wbat%
goto 盘符转换
:还原选择
echo :part_num "选择将选定的Ghost映像,还原到哪个区" [x]>%temp%\me.bak
type %temp%\hdd.ini|find /v "%ghodrv%" >>%temp%\me.bak
call vtm /T %temp%\me.bak %temp%\menu.bak
call w.bat list18 @%temp%\menu.bak:part_num
if errorlevel 100 goto Restore
if %wbat%#==# goto 还原选择
strings actsign=left %wbat%,13
strings actsign=right %actsign%,4
for %%a in (%actsign%) do set actsign=%%a
goto Restore
:end
for %%a in (wbat wcb1 gpos num gho ghodrv ghopart ghosign ghoname active actsign ghonum ghodate ghoy ghom ghofile ghoerr xz) do set %%a=
for %%a in (menu.bak hdd.tmp me.bak gho.tmp part.bat) do if exist %temp%\%%a del %temp%\%%a |
|