Problem with the choice command under ms-dos 8.0

Mario Zio
Mario Zio used Ask the Experts™
on
Hello,

I'm working on a script and I have problems running the choice command. This is :

:block1

choice /c:12 /n Format a:,g: ?
if errorlevel 1 goto a
if errorlevel 2 goto fine

:a
format a:
goto fine

:g
format g:
goto fine

:block2

choice /c:1234567 /n Format b:,c:,d:,e:,f:,a:,g: ?
if errorlevel 1 goto b
if errorlevel 2 goto c
if errorlevel 3 goto d
if errorlevel 4 goto e
if errorlevel 5 goto f
if errorlevel 6 goto a
if errorlevel 7 goto fine

:b
format b:
goto fine

:c
format c:
goto fine

:d
format d:
goto fine

:e
format e:
goto fine

:f
format f:
goto fine

:a
format a:
goto fine

:g
format g:
goto fine

:fine
shutdown

the problem born when I choose an option from 1 to 7 inside the Block 2 the script always jumps on block 1 and it executes the code under the :a section. How can I fix it ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Try

if errorlevel 7 goto fine
if errorlevel 6 goto a
if errorlevel 5 goto f
if errorlevel 4 goto e
if errorlevel 3 goto d
if errorlevel 2 goto c
f errorlevel 1 goto b

Write the errorlevels in order desc (both block1 and block 2 choice)
Actually I am surprised you did not experience this on BOTH blocks (even the first one  with only 2 choices!)  Perhaps you did not test both instances?

Froldan0 is correct... If you read the description of choice::errorlevel, you MUST test the errorlevel in DESCENDING order or you will ALWAYS just do the first one!  This is because errorlevel is NOT an equality test.  It tests for >=.
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
I believe I can help you with this but it will have to wait until tomorrow.  Gnight.
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

Mario ZioPsychologist

Author

Commented:
I think that it does not work,I attached the full code of the script.


@echo off

set drive1=c:
set drive2=d:
set percorso=reinstallazione

:osversion

%drive2%

if exist %drive2%\windows\winsxs\x86_1394.inf_31bf3856ad364e35_6.1.7600.16385_none_fb05acc2673b8783\1394.inf goto controlla_bit_7
rem if exist 1394.inf goto controlla_bit_7

if exist %drive2%\windows\winsxs\x86_1394.inf_31bf3856ad364e35_6.0.6001.18000_none_fb05acc2673b8783\1394.inf goto controlla_bit_vista
rem if exist 1394.inf goto controlla_bit_vista

if exist %drive2%\windows\zapotec.bmp goto _controlla_bit_xp
rem if exist zapotec.bmp goto _controlla_bit_xp

:controlla_bit_7
%drive2%
if exist %drive2%\windows\system32\wow64.dll goto copia_menu_7_amd64
if not exist %drive2%\windows\system32\wow64.dll goto copia_menu_7_x86

:controlla_bit_vista
%drive2%
if exist %drive2%\windows\system32\wow64.dll goto copia_menu_vista_amd64
if not exist %drive2%\windows\system32\wow64.dll goto copia_menu_vista_x86

:_controlla_bit_xp
%drive2%
if not exist %drive2%\windows\system32\wow64.dll goto bcopia_menu_xp_x86
if exist %drive2%\windows\system32\wow64.dll goto acopia_menu_xp_amd64

:copia_menu_7_amd64
echo Stai usando Windows 7 64 bit
pause
cls

ECHO ----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 7 64 bit,puoi installare solo questo nuovo S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 7 64 bit,you can install only this new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

choice /c:12 /n Scegli
IF ERRORLEVEL 2 goto riavvia
IF ERRORLEVEL 1 goto installa_seven_amd64

:copia_menu_vista_amd64

echo Stai usando Windows Vista 64 bit (You are using Windows Vista 64 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 64 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 64 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit     
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

choice /c:123 /n Scegli una di queste opzioni (Choose one of these options)  
IF ERRORLEVEL 3 goto riavvia
IF ERRORLEVEL 2 goto installa_vista_amd64
IF ERRORLEVEL 1 goto installa_seven_amd64

:acopia_menu_xp_amd64

echo Stai usando windows XP 64 bit (You are using Windows XP 64 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows XP 64 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows XP 64 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit        
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows XP 64 bit
ECHO . 
ECHO 4. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

choice /c:1234 /n Scegli una di queste opzioni (Choose one of these options) 
IF ERRORLEVEL 4 goto riavvia
IF ERRORLEVEL 3 goto installa_xp_amd64
IF ERRORLEVEL 2 goto installa_vista_amd64
IF ERRORLEVEL 1 goto installa_seven_amd64

:copia_menu_7_x86
echo Stai usando Windows 7 32 bit (You are using Windows 7 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 7 32 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 7 32 bit,you can install one of these new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Windows 7 32 bit
ECHO .
ECHO 3. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

choice /c:123 /n Scegli una di queste opzioni (Choose one of these options)
IF ERRORLEVEL 3 goto riavvia
IF ERRORLEVEL 2 goto installa_seven_x86
IF ERRORLEVEL 1 goto installa_seven_amd64

:copia_menu_vista_x86

echo Stai usando Windows Vista 32 bit (You are using Windows Vista 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows Vista 32 bit,puoi installare uno di questi nuovi S.O:
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows Vista 32 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows 7 32 bit
ECHO .
ECHO 4. Windows Vista 32 bit     
ECHO .
ECHO 5. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

choice /c:12345 /n Scegli una di queste opzioni (Choose one of these options)
IF ERRORLEVEL 5 goto riavvia
IF ERRORLEVEL 4 goto installa_vista_x86
IF ERRORLEVEL 3 goto installa_seven_x86
IF ERRORLEVEL 2 goto installa_vista_amd64
IF ERRORLEVEL 1 goto installa_seven_amd64

:bcopia_menu_xp_x86

echo Stai usando Windows XP 32 bit (You are using Windows XP 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows XP 32 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows XP 32 bit,you can install one of these new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit        
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows XP 64 bit
ECHO .
ECHO 4. Windows 7 32 bit
ECHO .
ECHO 5. Windows Vista 32 bit
ECHO .
ECHO 6. Windows XP 32 bit
ECHO .
ECHO 7. Termina lavoro (End job)
ECHO ------------------------------------------------------------------------------

choice /c:1234567 /n Scegli una di queste opzioni (Choose one of these options)
IF ERRORLEVEL 7 goto riavvia
IF ERRORLEVEL 6 goto installa_xp_x86
IF ERRORLEVEL 5 goto installa_vista_x86
IF ERRORLEVEL 4 goto installa_seven_x86
IF ERRORLEVEL 3 goto installa_xp_amd64
IF ERRORLEVEL 2 goto installa_vista_amd64
IF ERRORLEVEL 1 goto installa_seven_amd64

:installa_seven_amd64

echo installa_seven_amd64
pause
%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_7.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_vista_amd64

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_vista.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_xp_amd64

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_xp.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_seven_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_7.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_vista_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_vista.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_xp_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_xp.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:fine_lavoro
%drive1%
cd \
grub.exe

:riavvia
echo riavvia
pause

Open in new window

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
I can re-write for you as stands, however Quick clarification:

You are attempting to determine windows version and processor architecture while the computer is booted off a CD (Or other removable Media), prior to running the proper installation package from a list of packages correct?
Mario ZioPsychologist

Author

Commented:
I'm trying to determine version and processor architecture of the Windows installation on the first hard disk drive,because I want to boot the correct version of Windows PE 3 (x86 or amd64) using grub for Dos.
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Yeah, I figured something like that Script is underway, however I will rely on you for finalized testing because I don't have the Media and a spare VM to do that part at the moment + I'm working on other projects.

Is the Media always a CD or will it be writable? I have a tendency to write logs so if it will only be run on read-only media I don't want to bother trying to write them..
Mario ZioPsychologist

Author

Commented:
CD

Commented:
When reading ERRORLEVELs, you must read them in REVERSE order like this:

if ERRORLEVEL 7 goto fine
if ERRORLEVEL 6 goto a
if ERRORLEVEL 5 goto f
if ERRORLEVEL 4 goto e
if ERRORLEVEL 3 goto d
if ERRORLEVEL 2 goto c
if ERRORLEVEL 1 goto b

Commented:
Oh, and don't forget the first part....

   choice /c:12 /n Format a:,g: ?

   if ERRORLEVEL 2 goto fine
   if ERRORLEVEL 1 goto a
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Here you are I have revamped your entire Batch file it will be much more sturdy now =)

Anyway you were using Choice which can be problematic, so I changed it all to Use the Set command instead, I think you'll find it much simpler.

PS:  I note that you expect the batch file to be running on the C: Drive which is pretty common I admit for a CD to Boot and call itself.

  However I still gave you the ability to have the batch file determine which drive you are running the batch file on instead if you like, however I have set that functionality Off look into the batch file to see how you can turn it on if you would like it.

::------------------------------------------------------------------------------------------------::
:: Script: DeployWindows.Bat                                            				 		  ::
:: Version: 1.0                                                                                   ::
:: Copyright: Ben Personick                                                                       ::
:: Date: 2010-07-07                                                                               ::
::                                                                                                ::
::                                                                                                ::
:: Desc: This script runs Determins Processor Architeture and installs Windows.					  ::
::																								  ::
::  Based on: Stai usando Windows 7 64 bit By marietto2008 On 07/06/2010          		          ::
::------------------------------------------------------------------------------------------------::
:Begin
@ECHO OFF

::------------------------------------------------------------------------------------------------::
:: This section sets up default variable settings and sets the logging directory and file name.   ::
::------------------------------------------------------------------------------------------------::
:Start-Prep
	CALL :Start-Set-Date
	SET Preamble=DeployWindows --
	
	::--------------------------------------------------------------------------------------------::
	:: Sets Relative Paths used to search later.												  ::
	::--------------------------------------------------------------------------------------------::
	set InstallDir=reinstallazione
	SET WinRoot=Windows
	SET SysRoot=%WinRoot%\System32
	SET SxsRoot=%WinRoot%\WinSxs
	::--------------------------------------------------------------------------------------------::
	:: This is the Drive where you expect the OS to be installed to.							  ::
	::--------------------------------------------------------------------------------------------::
	SET Drive2=D:
	::--------------------------------------------------------------------------------------------::
	:: If Drive1 Set to NOMATCH it will find the drive the batch file is run in the context of.	  ::
	::--------------------------------------------------------------------------------------------::
	SET Drive1=C:
	::--------------------------------------------------------------------------------------------::
	:: This section finds the Drive The Batch File is run from for use later in the script        ::
	::--------------------------------------------------------------------------------------------::
	IF %Drive1% NEQ NOMATCH GOTO End-Find-Drive-Letter
	:Start-Find-Drive-Letter

		:Start-Find-DL-Inner
			FOR %%V IN (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) DO call :Start-DL-Loop %%V
			GOTO End-DL-Loop
			:Start-DL-Loop
				If %Drive1% NEQ NOMATCH GOTO :EOF
				SET TDrv=%1:
				echo TDrv = %TDrv%
				dir /D | FIND " Directory of " | Find "%TDrv%\"
				IF ERRORLEVEL 1 GOTO :EOF
				SET Drive1=%TDrv%
				GOTO :EOF
			:End-DL-Loop
			Echo End-DL-Loop
		:End-Find-DL-Inner
		ECHO %Preamble% Drive Run From = %Drive1%
	  	IF DstDrv == NOMATCH ECHO THE BATCH WAS NOT RUN FROM A HARD DRIVE!!
		REM IF DstDrv == NOMATCH pause
		IF DstDrv == NOMATCH GOTO :EOF
	:End-Find-Drive-Letter
	
	::--------------------------------------------------------------------------------------------::
	:: This Section Sets up logging variables.													  ::
	::--------------------------------------------------------------------------------------------::
	SET IDL=nul
	::Remove this GOTO Line to Enable Logging::
	GOTO End-IDir
	SET IDir=%Drive1%\DeployWindows\Log
	SET ILog=ILog_%TDate%_%TTime%.Log
	SET IDL=%IDir%\%ILog%
	:Start-IDir
		ECHO %Preamble% Checking For %IDir%
		IF EXIST %IDir% CALL :Start-Echo "%Preamble% IDir %IDir% -- Found!"
		IF EXIST %IDir% GOTO End-IDir
		ECHO %Preamble% Creating %IDir%
		mkdir %IDir%
	:End-IDir

	::--------------------------------------------------------------------------------------------::
	:: This Section Sets Default Values for match variables, don't change except for testing.	  ::
	::--------------------------------------------------------------------------------------------::
	SET BitLevel=32
	SET InstallOS=NOMATCH
	SET InstallBit=NOMATCH
	SET WinVer=NOMATCH
	SET FullWinVer=NOMATCH	
	

:End-Prep


::------------------------------------------------------------------------------------------------::
:: This Section performs checks to determine important information used later.				      ::
::------------------------------------------------------------------------------------------------::
:Start-Find-OS-Info

	:Start-Find-Bit
		IF Exist %drive2%\%SysRoot%\wow64.dll SET BitLevel=64
		CALL :Start-Echo "Architecture is %BitLevel%bit"
	:End-Find-Bit
	


	:Start-Find-OS-Version
		
		if exist %drive2%\%WinRoot%\zapotec.bmp SET WinVer=XP
		if %WinVer%==XP GOTO End-OS-VLoop
		for /F "Tokens=5" %%D in ('dir /A:D * "%drive2%\%SxsRoot%" ^| find "x86_1394.inf_31bf3856ad364e35_"') DO CALL :Start-OS-VLoop %%D
		GOTO End-OS-VLoop
		:Start-OS-VLoop
			SET Tbit=%1
			CALL :Start-Echo "%1 OR %Tbit%"
			If %WinVer% NEQ NOMATCH GOTO :EOF
			SET Tbit=%1
			CALL :Start-Echo "Tbit = %Tbit%"
			:Start-Check-Vista
			ECHO %Tbit% | FIND /I "_6.0.60"
			IF ERRORLEVEL 1 GOTO Start-Check-7
			SET WinVer=Vista
			GOTO :EOF
			:Start-Check-Vista

			:Start-Check-7
			ECHO %Tbit% | FIND /I "_6.1.76"
			IF ERRORLEVEL 1 GOTO :EOF
			SET WinVer=7
			GOTO :EOF
			:Start-Check-7
			
		:End-OS-VLoop
		CALL :Start-Echo "Windows Version is %WinVer%"
		
	:End-Find-OS-Version

:End-Find-OS-Info



:Start-Menu
	:Start-Draw-Menu
		REM CLS
		ECHO ----------------------------------------------------------------------------
		ECHO -- Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
		ECHO -- Stai usando Windows %WinVer% %BitLevel% bit,puoi installare uno di questi nuovi S.O :
		ECHO.
		ECHO Insert the DVD of the O.S you want to install and then press the related key.
		ECHO You are using Windows %WinVer% %BitLevel% bit,you can install one of these new O.S :
		ECHO -----------------------------------------------------------------------------

		:Start-Inner-menu
		
			:Start-764-Menu
				IF /I NOT %WinVer%%BitLevel%==764 GOTO End-764-Menu
				ECHO [1] Windows 7 64 bit
				GOTO End-Inner-menu
			:End-764-Menu
			
			:Start-Vista64-Menu
				IF /I NOT %WinVer%%BitLevel%==Vista64 GOTO End-Vista64-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				GOTO End-Inner-menu
			:End-Vista64-Menu
			
			:Start-XP64-Menu
				IF /I NOT %WinVer%%BitLevel%==XP64 GOTO End-XP64-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				ECHO.
				ECHO [3] Windows XP 64 bit
				GOTO End-Inner-menu
			:End-XP64-Menu
			
			:Start-732-Menu
				IF /I NOT %WinVer%%BitLevel%==732 GOTO End-732-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows 7 32 bit
				GOTO End-Inner-menu
			:End-732-Menu
			
			:Start-Vista32-Menu
				IF /I NOT %WinVer%%BitLevel%==Vista32 GOTO End-Vista32-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				ECHO.
				ECHO [3] Windows 7 32 bit
				ECHO.
				ECHO [4] Windows Vista 32 bit
				GOTO End-Inner-menu
			:End-Vista32-Menu
			
			:Start-XP32-Menu
				IF /I NOT %WinVer%%BitLevel%==XP32 GOTO End-XP32-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows 7 32 bit
				ECHO.
				ECHO [3] Windows Vista 64 bit
				ECHO.
				ECHO [4] Windows Vista 32 bit
				ECHO.
				ECHO [5] Windows XP 64 bit
				ECHO.
				ECHO [6] Windows XP 32 bit
				GOTO End-Inner-menu
			:End-XP32-Menu
		CALL :Start-Echo "Somehow You did not Match the Inner Menu.. WinVer Is %WinVer% BitLevel Is %BitLevel%"
		:End-Inner-menu
		
		ECHO .
		ECHO [Q] Termina lavoro (Quit)  
		ECHO -----------------------------------------------------------------------------
		ECHO.
	:End-Draw-Menu
	
	:Start-Menu-Choice
		IF /I %WinVer%%BitLevel%==764 SET /P Install=[1,Q]?
		IF /I %WinVer%%BitLevel%==Vista64 SET /P Install=[1,2,Q]?
		IF /I %WinVer%%BitLevel%==XP64 SET /P Install=[1,2,3,Q]?
		IF /I %WinVer%%BitLevel%==732 SET /P Install=[1,2,Q]?
		IF /I %WinVer%%BitLevel%==Visa32 SET /P Install=[1,2,3,4,Q]?
		IF /I %WinVer%%BitLevel%==XP32 SET /P Install=[1,2,3,4,5,6,Q]?
		IF /I %Install%==Q GOTO END
		FOR %%I in (7641,Vista641,XP641,7321,Vista321,XP321) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=7 & SET InstallBit=64
		FOR %%I in (7322,Vista322,XP322) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=7 & SET InstallBit=86
		FOR %%I in (Vista642,XP642,Vista323,XP323) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=vista & SET InstallBit=64
		FOR %%I in (Vista324,XP324) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=vista & SET InstallBit=86
		FOR %%I in (XP643,XP325) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=xp & SET InstallBit=64
		FOR %%I in (XP326) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=xp & SET InstallBit=86
	:End-Menu-Choice
	IF /I NOT %InstallOS%==NOMATCH GOTO Start-Install
	CALL :Start-Echo "The Value %Install% Is Invalid!"
	Pause
	GOTO Start-Menu
:End-Menu
CALL :Start-Echo "Somehow you got out of the Menu..  Aborting!"
GOTO :EOF

GOTO End-Subs
GOTO :EOF
:Start-Subs
	GOTO :End-Set-Date
	:Start-Set-Date
		SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
		SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
		GOTO :EOF
	:End-Set-Date
	GOTO End-Echo
	:Start-Echo
		Set TEcho=%~1
		ECHO %Preamble% %TEcho% --
		ECHO %Preamble% %TEcho% -- >> %IDL%
		GOTO :EOF
	:End-Echo

:End-Subs



:Start-Install
	CALL :Start-Echo "Start Install With OS = %InstallOS% and bit = %InstallBit%"
	CALL :Start-Echo "Copy %drive1%\%InstallDir%\os_name.txt TO %drive1%\%InstallDir%\tags\windows_%InstallOS%.txt"
	COPY "%drive1%\%InstallDir%\os_name.txt" "%drive1%\%InstallDir%\tags\windows_%InstallOS%.txt" /y
	CALL :Start-Echo "%drive1%\%InstallDir%\menu\x%InstallBit%\menu.lst TO %drive1%\menu.lst"
	COPY "%drive1%\%InstallDir%\menu\x%InstallBit%\menu.lst "%drive1%\menu.lst" /y
	CALL :Start-Echo "Running %drive1%\grub.exe"
	%drive1%\grub.exe
	GOTO riavvia
:End-Install

:riavvia
CALL :Start-Echo "Riavvia!"
pause

:End

Open in new window

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
PPS:

  I have mostly tested this, as I ran it initially with both drives Set to C: the menu works just fine.

  I was running this on Win764Bit and had no issues.

  Obviously you should test it too but I'm confident this script will solve all your issues.
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
One Final Note

In the Batch File Line 142 Reads: REM CLS


I had commented out this for testing purposes but it makes the menu look ugly so once you are satisfied please Remove the "REM" from the line so it will just do the CLS



Otherwise that's it.

Open in new window

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
I added an additional feature here, in this version it will test to make sure both drives exist and alert you if for some reason on e of the drives you were expecting to exist does not and will then abort the script.

Also you can now turn off and on the verbose output, if you set the variable TEST to YES then it will show you the extra output and stop the menu from clearing the screen, just in case you have any issues with the script =)

::------------------------------------------------------------------------------------------------::
:: Script: DeployWindows.Bat                                            				 		  ::
:: Version: 1.0                                                                                   ::
:: Copyright: Ben Personick                                                                       ::
:: Date: 2010-07-07                                                                               ::
::                                                                                                ::
::                                                                                                ::
:: Desc: This script runs Determins Processor Architeture and installs Windows.					  ::
::																								  ::
::  Based on: Stai usando Windows 7 64 bit By marietto2008 On 07/06/2010          		          ::
::------------------------------------------------------------------------------------------------::
:Begin
@ECHO OFF

::------------------------------------------------------------------------------------------------::
:: This section sets up default variable settings and sets the logging directory and file name.   ::
::------------------------------------------------------------------------------------------------::
:Start-Prep
	CALL :Start-Set-Date
	SET Preamble=DeployWindows --
	::--------------------------------------------------------------------------------------------::
	:: Set TEST to YES if you DO NOT want the Menu to Clear the Screen (For Debugging)			  ::
	::--------------------------------------------------------------------------------------------::
	SET TEST=NO
	::--------------------------------------------------------------------------------------------::
	:: Sets Relative Paths used to search later.												  ::
	::--------------------------------------------------------------------------------------------::
	set InstallDir=reinstallazione
	SET WinRoot=Windows
	SET SysRoot=%WinRoot%\System32
	SET SxsRoot=%WinRoot%\WinSxs
	::--------------------------------------------------------------------------------------------::
	:: This is the Drive where you expect the OS to be installed to.							  ::
	::--------------------------------------------------------------------------------------------::
	SET Drive2=D:
	::--------------------------------------------------------------------------------------------::
	:: If Drive1 Set to NOMATCH it will find the drive the batch file is run in the context of.	  ::
	::--------------------------------------------------------------------------------------------::
	SET Drive1=C:
	::--------------------------------------------------------------------------------------------::
	:: This section finds the Drive The Batch File is run from for use later in the script        ::
	::--------------------------------------------------------------------------------------------::
	IF /I %Drive1% NEQ NOMATCH GOTO End-Find-Drive-Letter
	:Start-Find-Drive-Letter

		:Start-Find-DL-Inner
			FOR %%V IN (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z) DO call :Start-DL-Loop %%V
			GOTO End-DL-Loop
			:Start-DL-Loop
				If %Drive1% NEQ NOMATCH GOTO :EOF
				SET TDrv=%1:
				echo TDrv = %TDrv%
				dir /D | FIND " Directory of " | Find "%TDrv%\"
				IF ERRORLEVEL 1 GOTO :EOF
				SET Drive1=%TDrv%
				GOTO :EOF
			:End-DL-Loop
			Echo End-DL-Loop
		:End-Find-DL-Inner
		ECHO %Preamble% Drive Run From = %Drive1%
	  	IF DstDrv == NOMATCH ECHO THE BATCH WAS NOT RUN FROM A HARD DRIVE!!
		REM IF DstDrv == NOMATCH pause
		IF DstDrv == NOMATCH GOTO :EOF
	:End-Find-Drive-Letter
	
	::--------------------------------------------------------------------------------------------::
	:: This Section Sets up logging variables.													  ::
	::--------------------------------------------------------------------------------------------::
	SET IDL=nul
	::Remove this GOTO Line to Enable Logging::
	GOTO End-IDir
	SET IDir=%Drive1%\DeployWindows\Log
	SET ILog=ILog_%TDate%_%TTime%.Log
	SET IDL=%IDir%\%ILog%
	:Start-IDir
		ECHO %Preamble% Checking For %IDir%
		IF EXIST %IDir% CALL :Start-Echo "%Preamble% IDir %IDir% -- Found!"
		IF EXIST %IDir% GOTO End-IDir
		ECHO %Preamble% Creating %IDir%
		mkdir %IDir%
	:End-IDir

	::--------------------------------------------------------------------------------------------::
	:: This Section Sets Default Values for match variables, don't change except for testing.	  ::
	::--------------------------------------------------------------------------------------------::
	SET BitLevel=32
	SET InstallOS=NOMATCH
	SET InstallBit=NOMATCH
	SET WinVer=NOMATCH
	SET FullWinVer=NOMATCH	
	

:End-Prep

:Start-Check-Drives
	SET DriveAbort=NO
	For %%E IN (%Drive1%,%Drive2%) DO CALL :Start-Check-Loop %%E
	GOTO END-Check-Loop
		:Start-Check-Loop
			IF /I %DriveAbort%==ABORT GOTO :EOF
			Set TDrive=%~1
			IF NOT Exist %TDrive% SET DriveAbort=ABORT
			GOTO :EOF
		:END-Check-Loop
	IF /I %DriveAbort%==ABORT CALL :Start-Echo "The Drive %TDrive% DOES NOT EXIST! -- Script Will Abort!"
	IF /I %DriveAbort%==ABORT GOTO :EOF
:End-Check-Drives
::------------------------------------------------------------------------------------------------::
:: This Section performs checks to determine important information used later.				      ::
::------------------------------------------------------------------------------------------------::
:Start-Find-OS-Info

	:Start-Find-Bit
		IF Exist %drive2%\%SysRoot%\wow64.dll SET BitLevel=64
		IF /I %TEST%==YES CALL :Start-Echo "Architecture is %BitLevel%bit"
	:End-Find-Bit
	


	:Start-Find-OS-Version
		
		if exist %drive2%\%WinRoot%\zapotec.bmp SET WinVer=XP
		if %WinVer%==XP GOTO End-OS-VLoop
		for /F "Tokens=5" %%D in ('dir /A:D * "%drive2%\%SxsRoot%" ^| find "x86_1394.inf_31bf3856ad364e35_"') DO CALL :Start-OS-VLoop %%D
		GOTO End-OS-VLoop
		:Start-OS-VLoop
			SET Tbit=%1
			IF /I %TEST%==YES CALL :Start-Echo "%1 OR %Tbit%"
			If %WinVer% NEQ NOMATCH GOTO :EOF
			SET Tbit=%1
			IF /I %TEST%==YES CALL :Start-Echo "Tbit = %Tbit%"
			:Start-Check-Vista
			ECHO %Tbit% | FIND /I "_6.0.60"
			IF ERRORLEVEL 1 GOTO Start-Check-7
			SET WinVer=Vista
			GOTO :EOF
			:Start-Check-Vista

			:Start-Check-7
			ECHO %Tbit% | FIND /I "_6.1.76"
			IF ERRORLEVEL 1 GOTO :EOF
			SET WinVer=7
			GOTO :EOF
			:Start-Check-7
			
		:End-OS-VLoop
		IF /I %TEST%==YES CALL :Start-Echo "Windows Version is %WinVer%"
		IF /I %WinVer%==NOMATCH CALL :Start-Echo "Windows Version is %WinVer%!  Script Will Abort, Turn On Debug Mode!"
		IF /I %WinVer%==NOMATCH GOTO :EOF
	:End-Find-OS-Version

:End-Find-OS-Info



:Start-Menu
	:Start-Draw-Menu
		IF /I %TEST% NEQ YES CLS
		ECHO ----------------------------------------------------------------------------
		ECHO -- Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
		ECHO -- Stai usando Windows %WinVer% %BitLevel% bit,puoi installare uno di questi nuovi S.O :
		ECHO.
		ECHO Insert the DVD of the O.S you want to install and then press the related key.
		ECHO You are using Windows %WinVer% %BitLevel% bit,you can install one of these new O.S :
		ECHO -----------------------------------------------------------------------------

		:Start-Inner-menu
		
			:Start-764-Menu
				IF /I NOT %WinVer%%BitLevel%==764 GOTO End-764-Menu
				ECHO [1] Windows 7 64 bit
				GOTO End-Inner-menu
			:End-764-Menu
			
			:Start-Vista64-Menu
				IF /I NOT %WinVer%%BitLevel%==Vista64 GOTO End-Vista64-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				GOTO End-Inner-menu
			:End-Vista64-Menu
			
			:Start-XP64-Menu
				IF /I NOT %WinVer%%BitLevel%==XP64 GOTO End-XP64-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				ECHO.
				ECHO [3] Windows XP 64 bit
				GOTO End-Inner-menu
			:End-XP64-Menu
			
			:Start-732-Menu
				IF /I NOT %WinVer%%BitLevel%==732 GOTO End-732-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows 7 32 bit
				GOTO End-Inner-menu
			:End-732-Menu
			
			:Start-Vista32-Menu
				IF /I NOT %WinVer%%BitLevel%==Vista32 GOTO End-Vista32-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows Vista 64 bit
				ECHO.
				ECHO [3] Windows 7 32 bit
				ECHO.
				ECHO [4] Windows Vista 32 bit
				GOTO End-Inner-menu
			:End-Vista32-Menu
			
			:Start-XP32-Menu
				IF /I NOT %WinVer%%BitLevel%==XP32 GOTO End-XP32-Menu
				ECHO [1] Windows 7 64 bit
				ECHO.
				ECHO [2] Windows 7 32 bit
				ECHO.
				ECHO [3] Windows Vista 64 bit
				ECHO.
				ECHO [4] Windows Vista 32 bit
				ECHO.
				ECHO [5] Windows XP 64 bit
				ECHO.
				ECHO [6] Windows XP 32 bit
				GOTO End-Inner-menu
			:End-XP32-Menu
		CALL :Start-Echo "Somehow You did not Match the Inner Menu.. WinVer Is %WinVer% BitLevel Is %BitLevel%"
		:End-Inner-menu
		
		ECHO .
		ECHO [Q] Termina lavoro (Quit)  
		ECHO -----------------------------------------------------------------------------
		ECHO.
	:End-Draw-Menu
	
	:Start-Menu-Choice
		IF /I %WinVer%%BitLevel%==764 SET /P Install=[1,Q]?
		IF /I %WinVer%%BitLevel%==Vista64 SET /P Install=[1,2,Q]?
		IF /I %WinVer%%BitLevel%==XP64 SET /P Install=[1,2,3,Q]?
		IF /I %WinVer%%BitLevel%==732 SET /P Install=[1,2,Q]?
		IF /I %WinVer%%BitLevel%==Visa32 SET /P Install=[1,2,3,4,Q]?
		IF /I %WinVer%%BitLevel%==XP32 SET /P Install=[1,2,3,4,5,6,Q]?
		IF /I %Install%==Q GOTO riavvia
		FOR %%I in (7641,Vista641,XP641,7321,Vista321,XP321) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=7 & SET InstallBit=64
		FOR %%I in (7322,Vista322,XP322) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=7 & SET InstallBit=86
		FOR %%I in (Vista642,XP642,Vista323,XP323) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=vista & SET InstallBit=64
		FOR %%I in (Vista324,XP324) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=vista & SET InstallBit=86
		FOR %%I in (XP643,XP325) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=xp & SET InstallBit=64
		FOR %%I in (XP326) do IF /I  %WinVer%%BitLevel%%Install%==%%I SET InstallOS=xp & SET InstallBit=86
	:End-Menu-Choice
	IF /I NOT %InstallOS%==NOMATCH GOTO Start-Install
	CALL :Start-Echo "The Value %Install% Is Invalid!"
	Pause
	GOTO Start-Menu
:End-Menu
CALL :Start-Echo "Somehow you got out of the Menu..  Aborting!"
GOTO :EOF

GOTO End-Subs
GOTO :EOF
:Start-Subs
	GOTO :End-Set-Date
	:Start-Set-Date
		SET TDate=%date:~10,4%-%date:~4,2%-%date:~7,2%
		SET TTime=%Time:~0,2%.%Time:~3,2%.%Time:~6,2%
		GOTO :EOF
	:End-Set-Date
	GOTO End-Echo
	:Start-Echo
		Set TEcho=%~1
		ECHO %Preamble% %TEcho% --
		ECHO %Preamble% %TEcho% -- >> %IDL%
		GOTO :EOF
	:End-Echo

:End-Subs



:Start-Install
	Echo.
	CALL :Start-Echo "Start Install With OS = %InstallOS% and bit = %InstallBit%"
	Echo.
	IF /I %TEST%==YES CALL :Start-Echo "Copy %drive1%\%InstallDir%\os_name.txt TO %drive1%\%InstallDir%\tags\windows_%InstallOS%.txt"
	COPY "%drive1%\%InstallDir%\os_name.txt" "%drive1%\%InstallDir%\tags\windows_%InstallOS%.txt" /y
	IF /I %TEST%==YES CALL :Start-Echo "%drive1%\%InstallDir%\menu\x%InstallBit%\menu.lst TO %drive1%\menu.lst"
	COPY "%drive1%\%InstallDir%\menu\x%InstallBit%\menu.lst "%drive1%\menu.lst" /y
	IF /I %TEST%==YES CALL :Start-Echo "Running %drive1%\grub.exe"
	%drive1%\grub.exe
	GOTO riavvia
:End-Install

:riavvia
CALL :Start-Echo "Riavvia!"
pause

:End

Open in new window

Mario ZioPsychologist

Author

Commented:
you used the command " SET /P " but it does not exist before and on MS-DOS 8.0,that's the latest version of DOS...
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
The command is actually "Set". It's a standard command in all versions of NT DOS and 9x DOS.

The newest version of DOS is 6.22.

DOS 8.0 is the virtual command shell that is part of windows 7 and Windows 2008.  That is why I tested on windows 7.

Did you try to run the bat file?  Di you have a way to communicate interactively?  If there is an issue I'd love to solve it..
Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
Okay, so I did some digging on this.

Very old versions of DOS do not support SET /P (at least 10 years old, Win 98 and prior basically)

Are you using Free-DOS?  (Bart-PE uses Free-DOS for instance.)

If you are, there are different libraries you need to import into your CD ISO in order to support either SET /P or CHOICE (The very same libraries apparently)  This sounds like exactly your issue too.

If you aren't running Free-Doss you are almost certainly running a Very old version of DOS, probably the Version of DOS which came with Windows 9x, which will give you a whole host of other problems in terms of reading the local hard disk of the computer as it woudl almost certainly be formatted with NTFS.  I foudn that They called The version of DOS with Windows 98 version 8.0 as it's official name (I guess you live and learn ^^)

The simple solution in that case is simply to make your boot disk using any New (Windows 2000 or greater) NT OS which have the NT Versions of DOS, and support the SET /P command or load the additional libraries into your original boot disk..  Which seems like it wwoudl be far more work.

Hope that wasn't too dense for reading ^^

Mario ZioPsychologist

Author

Commented:
I wrote the first version of the script using DOS 8.0 included in Windows ME because I could load into the memory the NTFS4DOS driver of Datapol and there was enough memory to run grub,too. Then I realized that I could not use the set command with the switch / P,because the P option was not inserted into the DOS 8.0 and then I tried FreeDOS. With it I can use Set with the switch / P, but unfortunately now I can not use anymore the NTFS4Driver from Datapol,because It takes too much memory and grub can't start. Now I don't know what to do...
Mario ZioPsychologist

Author

Commented:
I tried your script under WIndows 7,it works,but under FreeDOS it does not work. It causes a lot of sintax errors. I attached the version I wrote for FreeDos,it is less complicated compared to your,but it works perfectly. The problem is that I can't use it,because I haven't found an NTFS driver able to read the NTFS partitions without to take almost all RAM memory.
@echo off

set drive1=c:
set drive2=d:
set percorso=reinst~1

:osversion

%drive2%

if exist %drive2%\windows\winsxs\x86_1394.inf_31bf3856ad364e35_6.1.7600.16385_none_fb05acc2673b8783\1394.inf goto controlla_bit_7

if exist %drive2%\windows\winsxs\x86_1394.inf_31bf3856ad364e35_6.0.6001.18000_none_fb05acc2673b8783\1394.inf goto controlla_bit_vista

if exist %drive2%\windows\zapotec.bmp goto _controlla_bit_xp

:controlla_bit_7

%drive2%
if exist %drive2%\windows\system32\wow64.dll goto copia_menu_7_amd64
if not exist %drive2%\windows\system32\wow64.dll goto copia_menu_7_x86

:controlla_bit_vista

%drive2%
if exist %drive2%\windows\system32\wow64.dll goto copia_menu_vista_amd64
if not exist %drive2%\windows\system32\wow64.dll goto copia_menu_vista_x86

:_controlla_bit_xp

%drive2%
if not exist %drive2%\windows\system32\wow64.dll goto bcopia_menu_xp_x86
if exist %drive2%\windows\system32\wow64.dll goto acopia_menu_xp_amd64

:copia_menu_7_amd64

echo Stai usando Windows 7 64 bit (You are using Windows 7 64 bit)
pause
cls

ECHO ----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 7 64 bit,puoi installare solo questo nuovo S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 7 64 bit,you can install only this new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

set scegli=
 
set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 
if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto riavvia

ECHO "%scegli_menu_principale%" non è una opzione valida (is not a valid option)
goto copia_menu_7_amd64

:copia_menu_vista_amd64

echo Stai usando Windows Vista 64 bit (You are using Windows Vista 64 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 64 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 64 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit     
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

set scegli=
 
set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 
if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto installa_seven_amd64
if '%scegli%'=='3' goto riavvia

ECHO "%scegli%" non è una opzione valida (is not a valid option)
goto copia_menu_vista64

:acopia_menu_xp_amd64

echo Stai usando windows XP 64 bit (You are using Windows XP 64 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows XP 64 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows XP 64 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit        
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows XP 64 bit
ECHO . 
ECHO 4. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

set scegli=
 
set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 
if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto installa_seven_amd64
if '%scegli%'=='3' goto installa_xp_amd64
if '%scegli%'=='4' goto riavvia

ECHO "%scegli%" non è una opzione valida (is not a valid option)
goto acopia_menu_xp_amd64

:copia_menu_7_x86
echo Stai usando Windows 7 32 bit (You are using Windows 7 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows 7 32 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows 7 32 bit,you can install one of these new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Windows 7 32 bit
ECHO .
ECHO 3. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

set scegli=
 
set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 

if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto installa_seven_x86
if '%scegli%'=='3' goto riavvia

ECHO "%scegli%" non è una opzione valida (is not a valid option)
goto copia_menu_7_x86

:copia_menu_vista_x86

echo Stai usando Windows Vista 32 bit (You are using Windows Vista 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows Vista 32 bit,puoi installare uno di questi nuovi S.O:
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows Vista 32 bit,you can install one of these new O.S:
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows 7 32 bit
ECHO .
ECHO 4. Windows Vista 32 bit     
ECHO .
ECHO 5. Termina lavoro (End job)  
ECHO -----------------------------------------------------------------------------

set scegli=
 
set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 
if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto installa_vista_amd64
if '%scegli%'=='3' goto installa_7_x86
if '%scegli%'=='4' goto installa_vista_x86
if '%scegli%'=='5' goto riavvia

ECHO "%scegli%" non è una opzione valida (is not a valid option)
goto copia_menu_vista_x86

:bcopia_menu_xp_x86

echo Stai usando Windows XP 32 bit (You are using Windows XP 32 bit)
pause
cls

ECHO -----------------------------------------------------------------------------
ECHO Inserisci il DVD del S.O. che vuoi installare e poi scegli l'opzione. 
ECHO Stai usando Windows XP 32 bit,puoi installare uno di questi nuovi S.O :
ECHO.
ECHO Insert the DVD of the O.S you want to install and then press the related key.
ECHO You are using Windows XP 32 bit,you can install one of these new O.S :
ECHO -----------------------------------------------------------------------------
ECHO 1. Windows 7 64 bit        
ECHO .
ECHO 2. Windows Vista 64 bit
ECHO .
ECHO 3. Windows XP 64 bit
ECHO .
ECHO 4. Windows 7 32 bit
ECHO .
ECHO 5. Windows Vista 32 bit
ECHO .
ECHO 6. Windows XP 32 bit
ECHO .
ECHO 7. Termina lavoro (End job)
ECHO ------------------------------------------------------------------------------

set scegli= 

set /p scegli=Scegli una opzione tra quelle proposte (Choose one of these options). 

if '%scegli%'=='1' goto installa_seven_amd64
if '%scegli%'=='2' goto installa_vista_amd64
if '%scegli%'=='3' goto installa_xp_amd64
if '%scegli%'=='4' goto installa_seven_x86
if '%scegli%'=='5' goto installa_vista_x86
if '%scegli%'=='6' goto installa_xp_x86
if '%scegli%'=='7' goto riavvia

ECHO "%scegli%" non è una opzione valida (is not a valid option).
goto bcopia_menu_xp_x86

:installa_seven_amd64

echo installa_seven_amd64
pause
%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_7.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_vista_amd64

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_vista.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_xp_amd64

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_xp.txt /y
cd \menu\x64
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_seven_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_7.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_vista_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_vista.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:installa_xp_x86

%drive1%
copy %drive1%\%percorso%\os_name.txt %drive1%\%percorso%\tags\windows_xp.txt /y
cd \menu\x86
copy menu.lst %drive1%\ /y
goto fine_lavoro

:fine_lavoro
%drive1%
cd \
grub.exe
echo grub
pause

:riavvia
echo riavvia
pause

Open in new window

Ben Personick (Previously QCubed)Lead SaaS Infrastructure Engineer

Commented:
My scrip may be more wordy, however it is actually less complicated logically in many ways.

I understand your issue, I'm glad I got to the heart of it.

  However, you should be able to run quite a bit in DOS in 512K or 640 K (Which are you set to?)**

Have you built an NT Boot disk using windows 2000 or Windows NT? To see if that solves your problem?  The newer version of DOS should work just fine.

What boot disk builder are you using?  I would very much like to give a crack at the thing myself!

** Don't forget you can always load himem.sys to bump up DOS's available memory by using the system's RAM.
Mario ZioPsychologist

Author

Commented:
I've installed FreeDos 1.0 to the usb stick. We can close this question because you already did your work and I will give you the points. We can continue here :

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_26313137.html
Lead SaaS Infrastructure Engineer
Commented:
Awesome, glad I could get you to the heart of the problem!

Thanks for the points when you close this ticket.

I will continue to work with you in your new ticket as well =)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial