-@REM Set up environment at fisrt.\r
-\r
-@set BASETOOLS_DIR=%WORKSPACE_TOOLS_PATH%\Bin\Win32\r
-@set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
-@set DISK_LABEL=DUET\r
-@set PROCESSOR=""\r
-\r
-@echo on\r
-\r
-@if "%1"=="" goto Help\r
-@if "%2"=="" goto Help\r
-@if "%3"=="" goto Help\r
-@if "%4"=="" goto NoArch\r
-@set EFI_BOOT_DISK=%2\r
-@if "%4"=="IA32" set PROCESSOR=IA32\r
-@if "%4"=="X64" set PROCESSOR=X64\r
-@if %PROCESSOR%=="" goto WrongArch\r
-@set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\DEBUG_MYTOOLS\r
-\r
-@if "%1"=="floppy" goto CreateFloppy\r
-@if "%1"=="file" goto CreateFile\r
-@if "%1"=="usb" goto CreateUsb\r
-@if "%1"=="ide" goto CreateIde\r
+@REM Set up environment at first.\r
+\r
+set BASETOOLS_DIR=%EDK_TOOLS_BIN%\r
+set BOOTSECTOR_BIN_DIR=%WORKSPACE%\DuetPkg\BootSector\bin\r
+set DISK_LABEL=DUET\r
+set PROCESSOR=""\r
+set STEP=1\r
+\r
+if "%1"=="" goto Help\r
+if "%2"=="" goto Help\r
+if "%3"=="" goto Help\r
+if "%4"=="" goto Set_BootDisk\r
+if "%4"=="step2" (@set STEP=2) else @set TARGET_ARCH=%4\r
+if "%5"=="step2" @set STEP=2\r
+:Set_BootDisk\r
+set EFI_BOOT_DISK=%2\r
+if "%TARGET_ARCH%"=="IA32" set PROCESSOR=IA32\r
+if "%TARGET_ARCH%"=="X64" set PROCESSOR=X64\r
+if %PROCESSOR%=="" goto WrongArch\r
+call %WORKSPACE%\DuetPkg\SetEnv_%PROCESSOR%.bat\r
+set BUILD_DIR=%WORKSPACE%\Build\DuetPkg%PROCESSOR%\%TARGET%_%TOOL_CHAIN_TAG%\r
+\r
+if "%1"=="floppy" goto CreateFloppy\r
+if "%1"=="file" goto CreateFile\r
+if "%1"=="usb" goto CreateUsb\r
+if "%1"=="ide" goto CreateIde\r