China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-22 19:20
中国DOS联盟论坛 » DOS启动盘 & LOGO技术 (启动盘室) » Help----How to make a batch script that lets Ghost back up the image to the last partition View 6,547 Replies 28
Floor 16 Posted 2007-01-31 05:36 ·  中国 新疆 喀什地区 电信
新手上路
Credits 19
Posts 9
Joined 2007-01-08 04:24
19-year member
UID 75790
Gender Male
Status Offline
@echo off
set drv=c d e f g h i j k l m n o p q r s t u v w x y z
if "%1"=="" if "%last_drv%"=="" call %0 %drv%
:set_last
if "%1"=="" goto end
md %1:\last.drv>nul
if not exist %1:\last.drv\nul goto end
rd %1:\last.drv>nul
set last_drv=%1:
shift
goto set_last

:end
Is this batch script written correctly?
Floor 17 Posted 2007-01-31 10:33 ·  中国 广东 广州 珠江宽频
中级用户
★★
Credits 210
Posts 85
Joined 2007-01-14 12:38
19-year member
UID 76501
Gender Male
From 广东广州
Status Offline
When there is no CD - ROM and so on, the following views can be made:
1. The >nul in the md line seems not to work, because if the drive letter is valid, md does not produce information, and if the drive letter is invalid, >nul cannot shield the error message.
2. The method of building a temporary directory for judgment seems redundant. The if not... line can be simplified to if not exist %1:\nul goto end, and the previous two lines (md and rd lines) can be deleted, and the same purpose can be achieved.
3. To ghost the image to the last partition, the drive letter needs to be converted to a number.

[ Last edited by lizaoyou on 2007-1-30 at 09:47 PM ]
Floor 18 Posted 2007-01-31 10:42 ·  中国 河南 洛阳 联通
高级用户
★★
Credits 544
Posts 164
Joined 2004-10-17 12:00
21-year member
UID 32648
Gender Male
Status Offline
I post what I used for everyone to see

Judge the last partition and assign variables:
===========================
CLS

:1
FIND /I "%P%:%1" GHSTSTAT.TXT >NUL
IF ERRORLEVEL 1 GOTO 2
SET IMAGEDRV=%P%:%1
GOTO 1

:2

==============================================
Use GHSOT to backup and restore the target area
ghost -dd >NUL
set p=1
call FINDDRV.bat 1 2 3 4 5 6 7 8 9 10 11 12 13 14
ghost -clone,mode=pdump,src=1:1,dst=%imagedrv%:\System.gho -z5 -fx -sure

=================================

My one-key recovery download:

Download address:
Netcom:
http://www.yjwb.net/sysoft/onekey.rar
Telecom:
ftp://sysoft:sysoft@219.150.11.34/onekey.rar
我的留言簿

http://hnlyzhd.ys168.com 我的网络盘
Floor 19 Posted 2007-02-01 12:27 ·  中国 新疆 喀什地区 电信
新手上路
Credits 19
Posts 9
Joined 2007-01-08 04:24
19-year member
UID 75790
Gender Male
Status Offline
Originally posted by hnlyzhd at 2007-1-30 09:42 PM:
I'll post what I used for everyone to take a look

Judge the last partition and assign variables:
===========================
CLS

:1
FIND /I "%P%:%1" GHSTSTAT.TXT >NUL
IF ERRORLEVEL 1 GOTO 2
SET IMAGE ...

Can the person above explain your batch script for me?
Floor 20 Posted 2007-02-01 20:52 ·  中国 河南 洛阳 联通
高级用户
★★
Credits 544
Posts 164
Joined 2004-10-17 12:00
21-year member
UID 32648
Gender Male
Status Offline
Generate SHSTSTAT.TXT using GHOST -DD, then use the FIND command to find characters like 1:1, 1:2, etc. Find the maximum value and set it as the variable IMAGEDRV, which is the drive letter of the last partition! Then use the GHOST command-line parameters for automatic backup and recovery, and it's done!
我的留言簿

http://hnlyzhd.ys168.com 我的网络盘
Floor 21 Posted 2007-03-12 20:27 ·  中国 黑龙江 牡丹江 中移铁通
初级用户
Credits 74
Posts 30
Joined 2007-03-09 21:39
19-year member
UID 81219
Gender Male
Status Offline
Does hnlyzhd support multiple hard drives?
Floor 22 Posted 2007-03-14 01:59 ·  中国 广东 广州 番禺区 电信
中级用户
★★
脚本爱好者
Credits 238
Posts 93
Joined 2007-03-11 13:38
19-year member
UID 81417
Gender Male
From GZ
Status Offline
The following methods are suitable for the case of mixing NTFS and FAT32:

Among them, %hdd% is the number of hard drives (no more than 2, and detecting the line "key 3" can detect that there are 3 hard drives...), %partn% is the number of partitions (no more than 9)

set hdd=
set partn=
ghost.exe -dd >nul
find "Key 2" ghststat.txt >nul
if errorlevel 1 set "hdd=1" && goto 0pt
set hdd=2

rem Save the number of lines where "Key 1" exists to part.txt (indicating the number of partitions on the first hard drive, and the number of partitions on the second hard drive can be obtained by detecting the number of lines of "Key 2")
find "Key 1" /c ghststat.txt >part.txt
:0pt
find "0" part.txt >nul
if errorlevel 1 goto 1pt
set partn=0
goto checkok
:1pt
find "1" part.txt >nul
if errorlevel 1 goto 2pt
set partn=1
goto checkok
:2pt
find "2" part.txt >nul
if errorlevel 1 goto 3pt
set partn=2
goto checkok
:3pt
find "3" part.txt >nul
if errorlevel 1 goto 4pt
set partn=3
goto checkok
:4pt
find "4" part.txt >nul
if errorlevel 1 goto 5pt
set partn=4
goto checkok
:5pt
find "5" part.txt >nul
if errorlevel 1 goto 6pt
set partn=5
goto checkok
:6pt
find "6" part.txt >nul
if errorlevel 1 goto 7pt
set partn=6
goto checkok
:7pt
find "7" part.txt >nul
if errorlevel 1 goto 8pt
set partn=7
goto checkok
:8pt
find "8" part.txt >nul
if errorlevel 1 goto 9pt
set partn=8
goto checkok
:9pt
find "9" part.txt >nul
if errorlevel 1 goto err
set partn=9
goto checkok
:err
set partn=?
:checkok
del ghststat.txt
del part.txt

ghost -z3 -sure -fx -fro -auto -clone,mode=pdump,src=1:1,dst=1:%partn%\SYSC.GHO

[ Last edited by axi on 2007-3-13 at 01:34 PM ]
Floor 23 Posted 2007-03-14 05:08 ·  中国 湖南 株洲 电信
初级用户
Credits 56
Posts 13
Joined 2006-11-19 08:55
19-year member
UID 71039
Gender Male
Status Offline
ghost11 -dd >NUL
set p=1
call flast.bat 1 2 3 4 5 6 7 8 9 10 11 12 13 14
GHOST11.EXE -CLONE,MODE=PLOAD,SRC=%LastP%\SYSBAK.BBS:1,DST=1:1 -sure -FX -RB

flast.bat
:1
FIND /i "%p%:%1" GHSTSTAT.TXT >NUL
if errorlevel 1 goto 2
set LastP=%p%:%1
Shift
goto 1

:2
:del GHSTSTAT.TXT
Floor 24 Posted 2007-03-14 05:14 ·  中国 黑龙江 齐齐哈尔 中移铁通
初级用户
Credits 74
Posts 30
Joined 2007-03-09 21:39
19-year member
UID 81219
Gender Male
Status Offline
zzoym:
Can you explain this?

[ Last edited by jiaju8 on 2007-3-13 at 04:16 PM ]
Floor 25 Posted 2009-12-11 10:22 ·  中国 江苏 镇江 移动
新手上路
Credits 2
Posts 1
Joined 2009-12-10 13:50
16-year member
UID 156279
Gender Male
Status Offline
Can you write a complete batch script that makes Ghost back up the image to the last partition?
Floor 26 Posted 2009-12-22 10:40 ·  中国 安徽 马鞍山 联通
金牌会员
★★★★
Credits 3,946
Posts 1,884
Joined 2006-01-20 13:00
20-year member
UID 49283
Gender Male
Status Offline
Originally posted by cfenjin at 2009-12-11 10:22:
Can you write a complete batch script that makes Ghost back up the image to the last partition?


Complete ones can be found in ready-made one-click recovery tools.
Many one-click recoveries automatically back up to the last partition.
Windows 一键还原
http://www.yjhy.com
Floor 27 Posted 2009-12-23 18:31 ·  中国 辽宁 葫芦岛 联通
中级用户
★★
Credits 247
Posts 147
Joined 2009-04-09 20:52
17-year member
UID 142531
Gender Male
Status Offline
http://bbs.wuyou.com/viewthread.php?tid=138340&extra=page%3D1&page=1

It can be done in one sentence with awk.
Probably like this:
gdisk 1|awk '/PRIMARY/;/LOGICA/' |AWK 'END {printf "ghost -clone,mode pdump,src=1:1,dst=1:"FNR":";printf "%%c",92;printf "System.gho -z5 -fx -sure"}'>G.BAT

The obtained G.BAT is the script you need.
That is, use awk to analyze the partition information of the first hard disk obtained by gdisk to obtain the total number of partitions and generate the corresponding backup script g.bat.


gdisk and awk are needed

[ Last edited by DXSX on 2009-12-23 at 19:35 ]
Attachments
awk.rar (43.01 KiB, Downloads: 21)
Floor 28 Posted 2010-09-16 22:18 ·  中国 湖北 黄冈 电信
新手上路
Credits 8
Posts 4
Joined 2010-09-13 10:22
15-year member
UID 174097
Gender Male
Status Offline
I have one, let's see if it works
@echo off
XMSDSK 6144 /Y >nul
FINDRAMD >NUL
MD %RAMDRIVE%\TEMP
SET TMP=%RAMDRIVE%\TEMP
SET TEMP=%RAMDRIVE%\TEMP
COPY COMMAND.COM %RAMDRIVE%\ >NUL
PATH=%RAMDRIVE%\;%PATH%
SET COMSPEC=%RAMDRIVE%\COMMAND.COM
copy /y A:\ghost.exe %RAMDRIVE%\ >NUL
copy /y a:\finddrv.bat %RAMDRIVE%\ >NUL
copy /y a:\find.com %RAMDRIVE%\ >NUL
copy /y a:\restart.com %RAMDRIVE%\ >NUL

@cls
@echo.
@echo △△[Ghost Automatic Backup]
@echo.
@echo Back up partition 1 (C drive) of the first hard disk to the last partition\Ghost\GhostXP.gho
@echo.
@echo Attention! If there is a mirror file with the same name in the last partition, it will be overwritten.
@echo.
@echo Compression ratio: High compression
@echo.
@echo.
@A:\CHOICE Do you want to continue? Please choose Y or N
@If errorlevel 1 if not errorlevel 2 goto HF
@if errorlevel 2 if not errorlevel 3 goto Show
:HF

%RAMDRIVE%\
ghost -dd >NUL
set p=1
call FINDDRV.bat 1 2 3 4 5 6 7 8 9 10 11 12 13 14
ghost -clone,mode=pdump,src=1:1,dst=%imagedrv%:\ghost\GHOSTXP.GHO -z5 -sure -rb
@if errorlevel 2 if not errorlevel 3 goto Show
:Show
@echo.
@echo.
@echo.
@echo Press Ctrl + Alt + Del three keys at the same time and then restart the computer!
Floor 29 Posted 2010-09-26 15:41 ·  中国 广东 深圳 联通
新手上路
Credits 6
Posts 3
Joined 2010-07-27 10:29
15-year member
UID 171270
Gender Male
Status Offline
Forum Jump: