Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: FOR /F in DOS 7.10  (Read 4444 times)

0 Members and 1 Guest are viewing this topic.

NDog

  • Guest
FOR /F in DOS 7.10
« on: August 25, 2007, 05:14:16 AM »
I have a hard drive setup which is divided into 3 partitions.
The first is NTFS and has windows XP,
the second is NTFS and has got all the data saved on it,
the third is a small FAT32 partition stored at the end which has DOS7.10 installed

I use a boot loader to set the first partition active if I want to boot xp or set the third partition active if I want to boot into DOS7.10. The DOS7.10 has got full NTFS support through an app called NTFS4DOS.EXE which automatically loads on the autoexec.bat

I have GHOST.exe sitting on the 2nd partition which shows up as D: so I use a batch file called alive.bat which makes allows me to ghost image my windows partition very simply.

The only problem is that alive.bat is too simple and I want it to be a bit more powerful and be able to scan my ghost images folder so I can then simply press a button and load the all the *.gho files in my ghost images folder. The only thing is though DOS7.10 is not powerful? and I don't think it can even support the FOR /F command or even (more than 1 line enclosed in brackets).

I unfortunately don't even know where to get FOR.exe ? for dos. Maybe its impossible to scan files and create pseudo arrays in DOS 7.10, but I am hoping that some intellectual person will be able to help on this issue!!

The scripts are below for you to see what I mean

Thanks for your time!

Alive.bat (works fine in DOS7.10)
Code: [Select]
@echo off
cls
echo --------== Alive.bat - Ghosting Options ==--------
echo .
echo         Press a number to choose your option
echo .
echo .
echo  1 - Ressurection  (Restore Windows to original Image)
echo  2 - Norton Ghost  (Work in Norton Ghost)
echo  3 - DOS Prompt
echo .
echo .

choice /c:123

if errorlevel 3 goto THREE
if errorlevel 2 goto TWO
if errorlevel 1 goto ONE

:ONE
ghost.exe @c:\restore.txt
goto end

:TWO
d:
cd image\ghost
call c:\ghost.exe
c:
goto end

:THREE
goto end

:END

NPGS.bat (Concept script file works in windows XP, not in DOS7.10) and I want this to work in DOS7.10!!!!!!
Code: [Select]
@echo on
setlocal enabledelayedexpansion

set windrive=e:
set ghostdrive=d:
set ghostdir=Image\Ghost
set ghostexe=c:\tools\ghost.exe

cls
echo --------== Nathan Ghost System - Ghosting Options ==--------
echo.
echo         Press a number to choose your option
echo.
echo.
echo  1 - Restore Image  (Restore a Ghost Image)
echo  2 - Update Image  (Update existing Ghost Image)
echo  3 - Norton Ghost  (Work in Norton Ghost)
echo  4 - DOS Prompt
echo.
echo.

choice /c:1234
if errorlevel 4 (
goto :END
)
if errorlevel 3 (
set jump=MANUAL
goto :PREGHOST
)
if errorlevel 2 (
set jump=AUTO
set option=Update
goto :PREGHOST
)
if errorlevel 1 (
set jump=AUTO
set option=Restore
goto :PREGHOST
)

:PREGHOST
REM Deletes unneccesary system files and runs a scandisk/chkdsk
%windrive%
cd\
if exist pagefile.sys (
attrib -r -a -s -h pagefile.sys
del pagefile.sys
)
if exist hiberfil.sys(
attrib -r -a -s -h hiberfil.sys
del hiberfil.sys
)
deltree /y temp
scandisk /all /autofix /nosave /nosummary
del scandisk.log
CHKDSKG.EXE

%ghostdrive%
cd\
cd "%ghostdir%"

goto :%jump%

:AUTO
REM Scans the folder for *.gho files and creates a pseduo-array
set count=0
for /f "tokens=*" %%g in ('dir /b "*.gho"') do (
set ghost=%%~g
set /a count+=1
set _ghost/!ghost!=!count!
)

:menu/top
REM Creates a menu to choose which file you want to load
call :menu/dis
set _filechoice=
echo.
set /p "_filechoice=Choose a number: "
call :menu/chk
if not defined ghostfile goto :menu/top
goto :LOADGHOSTFILE
:menu/dis
echo --------== Nathan Ghost System - Ghosting Options ==--------
echo.
echo      Please select a Ghost file to %option%
echo.
:menu/chk

set ghostfile=
for /f "tokens=2* delims=/=" %%a in ('set _ghost/') do (
    if /i "%0" EQU ":menu/dis" echo:^(%%~b^) %%~a
    if /i "%0" EQU ":menu/chk" (
        if /i "%_filechoice%" EQU "%%~b" (
            set ghostfile=%%a
        )
    )
)
goto :EOF


:LOADGHOSTFILE
REM Loads the specified ghost image file
echo.
if "%option%" EQU "Restore" goto :RESTOREIMAGE
if "%option%" EQU "Update" goto :UPDATEIMAGE

:RESTOREIMAGE
echo Warning: You are about to overwrite windows system partition with ghost image file %ghostfile%
echo Please make sure you have backed up all important data on the windows partition to an alternative location before continuing this operation
pause
%ghostexe% -clone,MODE=pload,SRC=%ghostdrive%\%ghostdir%\%ghostfile%:1,DST=1:1,-rb

goto :END

:UPDATEIMAGE
echo Warning: You are about to overwrite ghost image file %ghostfile%.
echo Please ensure you are creating a clean image and have run a virus-scan & spyware scan before continuing this operation
pause
%ghostexe% -dump,MODE=pload,SRC=%ghostdrive%\%ghostdir%\%ghostfile%:1,DST=1:1,-rb
goto :END


:MANUAL
%ghostexe%
goto :END


:END
« Last Edit: August 25, 2007, 03:47:11 PM by NDog »

contrex

  • Guest
Re: FOR /F in DOS 7.10
« Reply #1 on: August 27, 2007, 01:33:58 AM »
As Todd Vargo told you in alt.msdos.batch, "the whole idea
of creating a dynamic menu of .gho image files is basically reinventing the
wheel. Ghost already provides its own menu system for selecting from
existing image files."