Here's my situation:
I was asked to create a bootdisk which starts ghost automatically and puts a ghost image on the harddisk, then display hardware info.
So I found UBCD (which works great) and had this:
- UBCD on a USB drive
- Booting OK, added Ghost & HWinfo together in 1 archive, all working fine
- Autorun ghost on startup using MENU DEFAULT and TIMEOUT
- USB drive is recognised as Drive #1, with drive letter C: (%CDDRV% is C:)
However I ended up with an empty USB stick after each run because the ghost command was set to overwrite Disk#1.
So I needed something that would check all drives, and find out if
a. they exist
b. they don't contain %CDDRV% partition
c. they haven't been ghosted already.
first attempt: fdisk /dump
So first I added FDISK to the archive and read fdisk.exe /dump using the following.
Code: Select all
rem create file with relevant lines from fdisk fdisk.exe /dump | xgrep ": [0-9]" > fdump.txt rem this retrieves the line with drive info for %cddrv% from fdisk dump xgrep -ni %cddrv% fdump.txt | lmod /S: [$1] | nset linenr=$0 call var set linenr=(%linenr%-1)
second attempt: fdisk /info #drivenr
I later found out you can call fdisk /info with a driveletter and this is the setup I now use:
the relevant lines without the plumbing and logging and stuff:
Code: Select all
rem loop drives 1 through 8 for %%A in (1 2 3 4 5 6 7 8) do call %0 : dsk %%A rem call fdisk with drive number and read output. fdisk /info %1 | xgrep -i ": [0-9]" | nset found=$0 if "%found%"=="" goto eof rem call fdisk with drive number and retrieve the first partition fdisk /info %1 | xgrep -i "^ [A-Z]:" | lmod /S: [$1] | nset found=$0 rem check for UBCD and erased drives if "%found%:"=="%cddrv%" goto cddrvnoterased if exist %found%:\erased.txt goto drivealreadyerased rem insert stuff to do with disk here...
- I am still looking for a way to display output to the screen between ghosts, sort of a progress indication instead of using a log file. (ghost clears the screen even when run without GUI.)
- I have added FDISK, GHOST and HWINFO to the same archive to be able to use them all directly - I don't want to open them manually from the menu and then start a batfile or something, no user input should be required. Is this possible without repacking everything you need in a single archive?
- Also, what if there are more than 8 drives? FDISK doesn't support that it seems, and I don't see it happening soon, but still..
- And if there is a way to read and loop through lines from a file, that would also help for other problems. I could not find anything usable - might create a dirty hack soon.
That's it for now
Other suggestions to do things easier or better of course also welcome.
Below the complete listing, hope this helps someone.
One last thing, be very careful with this if you use it with ghost like me..
It resulted in some nice "hey it's not starting windows? .. erased drive?! nooo!!" moments
Code: Select all
@if "%debug%"=="" echo off if "%1"==":" if not "%2"=="" goto %2 set log=ghostlog.txt for %%A in (1 2 3 4 5 6 7 8) do call %0 : dsk %%A echo --- Erase Log --- type %log% del %log% set log= pause call hwinfo.exe goto eof :dsk shift shift echo checking drive %1 >> %log% fdisk /info %1 | xgrep -i ": [0-9]" | nset found=$0 if "%found%"=="" goto eof echo drive found.. inspecting drive.. >> %log% fdisk /info %1 | xgrep -i "^ [A-Z]:" | lmod /S: [$1] | nset found=$0 if "%found%:"=="%cddrv%" goto cddrvnoterased if exist %found%:\erased.txt goto drivealreadyerased echo all OK.. erasing drive %1.. >> %log% ghost.exe -fni -clone,mode=load,src=ERASE.GHO,dst=%1 -quiet -sure echo drive %1 erased! >> %log% goto eof :cddrvnoterased echo drive %1 contains boot partition %cddrv%\. erase cancelled. >> %log% goto eof :drivealreadyerased echo drive %1 already erased. erase cancelled. >> %log% goto eof rem ** other stuff here ** :eof