cd %~dp0
@echo off

if exist C:\dispw.tag goto :Begin

@echo disable EMMC Write Protect
WinBootSeq.exe -lock off
ping 127.0.0.1 -n 3
echo disable EMMC Write Protect>C:\dispw.tag
shutdown -f -r -t 2
pause

:Begin
IF EXIST SMBIOS.CFG DEL /F /Q SMBIOS.CFG
IF EXIST DUMP_SMBIOS.CFG DEL /F /Q DUMP_SMBIOS.CFG 
timeout 1

::Smbios_Utility.exe /dump
:Dump
QCFactoryTool.exe /RawFS SMBIOS GetFileData SMBIOS\SMBIOS.CFG SMBIOS.CFG 0
timeout 3
if not exist SMBIOS.CFG goto :Dump

:inputBegin
set /p strType=Please enter the type of string to write(pn/mt/ln/uu):
set /p string=Please enter a string to write:


if /i "%strType%" == "PN" set PN="%string%" & goto :Product_name
if /i "%strType%" == "mt" set Cust_PN_1="%string%" & goto :MTM_PN
if /i "%strType%" == "ln" set SN="%string%" & goto :Serial_Number
if /i "%strType%" == "fd" set FN="%string%" & goto :Family_name
if /i "%strType%" == "pjn" set Mulan="%string%" & goto :project_PN
if /i "%strType%" == "uu" set UUID="%string%" & goto :UUID

@echo ************************************************************
@echo            ***** The input is abnormal, Please confirm *****
@echo            *****        Press any key to restart       *****
@echo ************************************************************
pause>nul
goto :Begin


@echo *********************************************
@echo            ***** Begin Creat CFG *****
@echo *********************************************

:Product_name
@echo ***************** 1.Product name  ***************
Smbios_Utility.exe /w /pn "%PN%"
timeout 1
goto :inputEnd

:MTM_PN
@echo ***************** 2. MTM PN *****************
Smbios_Utility.exe /w /mt "%Cust_PN_1%"
timeout 1
goto :inputEnd


:Serial_Number
@echo ***************** 3. Serial Number *************
Smbios_Utility.exe /w /ln "%SN%"
timeout 1
goto :inputEnd

:Family_name
@echo ***************** 4. Family name ***************
Smbios_Utility.exe /w /fd "%FN%"
timeout 1
goto :inputEnd

:project_PN
@echo ***************** 5. project PN ***************
Smbios_Utility.exe /w /pjn "%Mulan%"
timeout 1
goto :inputEnd

:UUID
@echo ***************** 6. UUID *********************
Smbios_Utility.exe /w /uu "%UUID%"
timeout 1
goto :inputEnd

:inputEnd
set /p OtherStr=Continue write other value pls press "Y", otherwise press "N":
if /i "%OtherStr%" == "Y" goto :inputBegin


@echo *********************************************
@echo            ***** End Creat CFG *****
@echo *********************************************

@echo ***************** Foramt SMBIOS *********************
QCFactoryTool.exe /RawFS SMBIOS Format 512 1 0
timeout 3
@echo ***************** Write SMBIOS.CFG 2 SMBIOS *********************
QCFactoryTool.exe /SMBIOS SMBIOS.CFG

:Write_DMI_end
@echo BACKUP SMBIOS.CFG
Smbios_Utility.exe /dump
timeout 1
if exist DUMP_SMBIOS.CFG copy DUMP_SMBIOS.CFG SMBOIS_WRITE.CFG /Y

timeout 1
::shutdown -f -r -t 3
pause
goto end

:end
@echo disable EMMC Write Protect
if exist C:\dispw.tag del /f /q C:\dispw.tag
WinBootSeq.exe -lock on
ping 127.0.0.1 -n 3
color 27
@echo ======================pass=======================
@echo ======================pass=======================
@echo ======================pass=======================
pause
shutdown -f -r -t 4
pause