@echo off
@rem This script is called by x:\Windows\System32\Startnet.cmd – WinPE
@echo.
@echo.
@echo.
@echo Running Intel Optimization powercfg for improved imaging times
@echo.
@echo call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
call powercfg /s 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
@echo.
@echo.
@rem
@rem This is the default product key being used:
set productkey=37GNV-YCQVD-38XP9-T848R-FC2HD
@rem
@rem Home/Core: 37GNV-YCQVD-38XP9-T848R-FC2HD
@rem Pro: NF6HC-QH89W-F8WYV-WWXV4-WFG6P
@rem Enterprise: GN7FR-4QK4T-8XPDY-P2RYF-QGP4G
@echo.
@rem *****************************************************************
@rem List all the disks, then search the volumes of each one to see
@rem which disks may have "Winpe" in the label. We will ignore that
@rem disk and use the first disk without the Winpe label that we find.
@rem *****************************************************************
@echo.>x:\listdisk.txt
@echo list disk>>x:\listdisk.txt
@echo exit>>x:\listdisk.txt
echo x:\listdisk.txt
@echo call diskpart /s x:\listdisk.txt
call diskpart /s x:\listdisk.txt>x:\Disks.txt
@echo.
@rem Set Disk equal to blank to start
set disk=
@echo.
@rem
@rem This line will write a diskpart script to select the disk and detail it's contents.
@rem We use this output to find a disk that does NOT have Winpe as the volume label.
@rem That disk will have the OS installed to it. This way you can exclude USB from diskpart.
@rem
@rem This works around the issue where the USB key is sometimes enumerated as disk 0 and the
@rem SSD is disk 1.
@rem
for /f "skip=8 tokens=2" %%A in (x:\Disks.txt) do (
@echo sel disk %%A>x:\Par.txt
@echo det disk>>x:\Par.txt
@echo exit>>x:\Par.txt
if NOT "%%A"=="DiskPart…" call :ListPar %%A
)
if "%Disk%"=="" echo No disk found without a volume label of "Winpe"&& set disk=0
@echo Using Disk "%Disk%"
@echo.
@echo.
@echo.
@rem *****************************************************************
@rem Detect if System is booted into UEFI mode or Bios mode
@rem *****************************************************************
for /f "tokens=2* delims= " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') do set Firmware=%%B
@echo.
if %Firmware%==0×1 goto :Biosmode
if %Firmware%==0×2 goto :UEFImode
Goto :END
:UEFImode
@echo.
@rem ************************
@rem UEFI SECTION
@rem ************************
@echo The PC is booted in UEFI mode
@echo.>x:\winpart.txt
@echo select disk "%Disk%">>x:\winpart.txt
@echo clean>>x:\winpart.txt
@echo convert gpt>>x:\winpart.txt
@echo create partition efi size=100>>x:\winpart.txt
@echo format quick fs=fat32 label="System">>x:\winpart.txt
@echo assign letter="S">>x:\winpart.txt
@echo create partition msr size=16>>x:\winpart.txt
@echo create partition primary>>x:\winpart.txt
@echo format quick fs=ntfs label="Windows">>x:\winpart.txt
@echo assign letter="W">>x:\winpart.txt
@echo shrink desired=800>>x:\winpart.txt
@echo create partition primary>>x:\winpart.txt
@echo format quick fs=ntfs label="Recovery">>x:\winpart.txt
@echo assign letter="R">>x:\winpart.txt
@echo set id="de94bba4-06d1-4d40-a16a-bfd50179d6ac">>x:\winpart.txt
@echo gpt attributes=0×8000000000000001>>x:\winpart.txt
@echo exit>>x:\WinPart.txt
Goto :WINPARTSECTION
:Biosmode
@rem ************************
@rem BIOS SECTION
@rem ************************
@echo The PC is booted in BIOS mode
@echo The PC is booted in BIOS mode>x:\Bios.txt
@echo.>x:\winpart.txt
@echo select disk "%Disk%">>x:\winpart.txt
@echo clean>>x:\winpart.txt
@echo create partition primary size=100>>x:\winpart.txt
@echo active>>x:\winpart.txt
@echo format quick fs=fat32 label="System">>x:\winpart.txt
@echo assign letter="S">>x:\winpart.txt
@echo create partition primary>>x:\winpart.txt
@echo format quick fs=ntfs label="Windows">>x:\winpart.txt
@echo assign letter="W">>x:\winpart.txt
@echo exit>>x:\winpart.txt
@echo.
:WINPARTSECTION
@echo Winpart.txt now contains…..
@echo.
type x:\winpart.txt
@echo.
@echo.
@echo *****************************************************************
@echo Setting up the partition table
@echo *****************************************************************
@echo call diskpart /s x:\winpart.txt
diskpart /s x:\winpart.txt
@echo.
@echo.
@echo *****************************************************************
@rem Map drive letter for Install.wim
@echo *****************************************************************
@echo.>x:\ListVol.txt
@echo List volume>>x:\ListVol.txt
@echo exit>>x:\ListVol.txt
@echo call diskpart /s x:\ListVol.txt
call diskpart /s x:\ListVol.txt>x:\Output.txt
@echo.
@echo.
@rem Go through each drive letter, looking for the images\Install.txt file
for /f "skip=8 tokens=3" %%A in (x:\Output.txt) do (
if exist %%A:\images\install.txt set InstallPath=%%A:\images&& echo "Found device with images folder and install.txt file"
)
@echo.
@echo.
@rem Check InstallPath was found and there are images in it.
if NOT EXIST %InstallPath%\Install.wim echo "Install.wim NOT found." && goto :Error
@echo Install.wim FOUND at %InstallPath%\images\install.wim
@echo.
@echo.
@echo Making directories…
md w:\recycler\scratch
if %errorlevel% NEQ 0 echo "Failed to make w:\recycler\scratch directory" && goto :error
@echo.
md r:\recovery\windowsre
if %errorlevel% NEQ 0 echo "Failed to make m:\recovery\windowsre directory" && goto :error
@echo.
@echo *****************************************************************
@echo Applying the Windows image from the USB
@echo *****************************************************************
@echo call DISM /Apply-Image /ImageFile:%InstallPath%\install.wim /Index:1 /ApplyDir:w:\ /Compact /ScratchDir:w:\recycler\SCRATCH
call DISM /Apply-Image /ImageFile:%InstallPath%\install.wim /Index:1 /ApplyDir:w:\ /Compact /ScratchDir:w:\recycler\SCRATCH
if %errorlevel% NEQ 0 echo "Failed to apply image to w:" && goto :error
@echo.
@echo.
@echo.
@echo *****************************************************************
@echo Add default product key
@echo *****************************************************************
@echo call DISM /Image:w: /Set-ProductKey:%productkey%
call DISM /Image:w: /Set-ProductKey:%productkey%
if %errorlevel% NEQ 0 echo "Failed to set productkey." && goto :error
@echo.
@echo.
@echo.
@echo *****************************************************************
@rem Move WinRE to Recovery Partition
@echo *****************************************************************
@echo.
@echo Modifying attributes of winre.wim so we can move it.
attrib w:\Windows\System32\recovery\winre.wim -s -h -a -r
@echo move w:\Windows\System32\recovery\winre.wim r:\recovery\windowsre
move w:\Windows\System32\recovery\winre.wim r:\recovery\windowsre
if %errorlevel% NEQ 0 echo "Failed to move winre.wim to r:\recovery\windowsre" && goto :error
@echo.
@echo reset attributes now
attrib r:\Recovery\Windowsre\winre.wim +s +h +a +r
@echo.
@echo.
@echo *****************************************************************
@echo Setting the boot environment
@echo *****************************************************************
@echo call w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS /s s: /f all
w:\WINDOWS\SYSTEM32\BCDBOOT w:\WINDOWS /s s: /f all
if %errorlevel% NEQ 0 echo "Failed to set boot information" && goto :error
@echo.
@echo.
@echo.
@echo *****************************************************************
@echo Setting the recovery environment
@echo *****************************************************************
@echo w:\windows\system32\reagentc /SetREImage /Path r:\RECOVERY\WINDOWSRE /target w:\windows
w:\windows\system32\reagentc /SetREImage /Path r:\RECOVERY\WINDOWSRE /target w:\windows
if %errorlevel% NEQ 0 echo "Failed to set recovery information" && goto :error
@echo.
@echo.
@echo.
@echo *****************************************************************
@echo Copying over Unattend.xml to use on factory floor if it exists
@echo *****************************************************************
@echo if EXIST %WinPESource%Scripts\Unattend.xml copy %WinPESource%Scripts\Unattend.xml w:\Windows\Panther /y
if EXIST %WinPESource%Scripts\Unattend.xml copy %WinPESource%Scripts\Unattend.xml w:\Windows\Panther /y
@echo.
@echo *****************************************************************
@echo Copying over NON Scanstate Packages, if they exist.
@echo IF YOU COPY OVER SCANSTATE PPKG, THIS CAUSE IMAGE TO FAIL DURING RECOVERY
@echo *****************************************************************
@echo if EXIST %WinPESource%Scripts\*.ppkg copy %WinPESource%Scripts\*.ppkg r:\Recovery\Customizations /y
if EXIST %WinPESource%Scripts\*.ppkg copy %WinPESource%Scripts\*.ppkg r:\Recovery\Customizations /y
@echo.
@echo *****************************************************************
@echo Copying over resetconfig.xml and assets, if they exist.
@echo *****************************************************************
@echo if EXIST %WinPESource%Scripts\Recovery\OEM\resetconfig.xml xcopy %WinPESource%Scripts\Recovery\*.* w:\Recovery /e /y
if EXIST %WinPESource%Scripts\Recovery\OEM\resetconfig.xml xcopy %WinPESource%Scripts\Recovery\*.* w:\Recovery /e /y
@echo.
@echo.
@echo *****************************************************************
@echo Copying over resetconfig.xml and assets, if they exist.
@echo *****************************************************************
@echo if EXIST %WinPESource%Scripts\LayoutModification.xml copy %WinPESource%Scripts\LayoutModification.xml w:\users\default\appdata\local\Microsoft\Windows\Shell\ /y
if EXIST %WinPESource%Scripts\LayoutModification.xml copy %WinPESource%Scripts\LayoutModification.xml w:\users\default\appdata\local\Microsoft\Windows\Shell\ /y
@echo.
@echo.
@echo.
@echo *****************************************************************
@echo Copying over oobe.xml.
@echo *****************************************************************
@echo xcopy %WinPESource%Scripts\Recovery\OEM\Scripts\oobexml\Oobe\*.* w:\Windows\System32\oobe\ /e /y
xcopy %WinPESource%Scripts\Recovery\OEM\Scripts\oobexml\Oobe\*.* w:\Windows\System32\oobe\ /e /y
@echo.
@echo.
@echo *****************************************************************
@echo Copy over Test tools to \TEST_TOOL
@echo \TEST_TOOL SHOULD BE DELETED PRIOR TO SHIPPING
@echo *****************************************************************
@echo %WinpeSource%Scripts\7za.exe x w:\TEST_TOOL.zip -oW:\
%WinpeSource%Scripts\7za.exe x %WinpeSource%TEST_TOOL.zip -oW:\
if %errorlevel% NEQ 0 echo "Error when run %WinpeSource%Scripts\7za.exe x w:\TEST_TOOL.zip" && goto :error
@echo.
@echo.
@echo *****************************************************************
@echo Copy over Cleanup.cmd link to desktop
@echo *****************************************************************
if EXIST %WinPESource%Scripts\Cleanup.cmd copy %WinPESource%Scripts\Cleanup.cmd w:\Users\Administrator\Desktop /y
@echo.
@echo.
@echo *****************************************************************
@echo Copy over Customer_Test.cmd link to desktop
@echo *****************************************************************
if EXIST %WinPESource%Scripts\Customer_Test.cmd copy %WinPESource%Scripts\Customer_Test.cmd w:\Users\Administrator\Desktop /y
@echo.
@echo.
@echo *****************************************************************
@echo Copy over SMT_Shutdown.cmd link to desktop
@echo *****************************************************************
if EXIST %WinPESource%Scripts\SMT_Shutdown.cmd copy %WinPESource%Scripts\SMT_Shutdown.cmd w:\Users\Administrator\Desktop /y
@echo.
@echo.
@echo *****************************************************************
@echo Copy over SMT_TEST.cmd link to desktop
@echo *****************************************************************
if EXIST %WinPESource%Scripts\SMT_TEST.cmd copy %WinPESource%Scripts\SMT_TEST.cmd w:\Users\Administrator\Desktop /y
@echo.
@echo.
@echo *****************************************************************
@echo Image deployment COMPLETE. Type EXIT from Command
@echo Prompt to restart or turn off device.
@echo *****************************************************************
goto :END
:ERROR
@echo.
@echo An error has been detected.
@echo.
goto :END
:ListPar
@REM This section is to bring a disk number and use it to List Partitions
@echo.
set TempDisk=%1
diskpart /s x:\Par.txt>x:\ParOutput.txt
for /f "skip=26 tokens=4" %%A in (x:\ParOutput.txt) do (
if /i NOT "%%A"=="Winpe" set Disk=%TempDisk%
)
Goto :EOF
:END
@rem
@rem Get finish time so we can evaluate total WinPE phase time.
@rem
call |time>x:\StopTime.txt
@rem
@rem Now parse both files to display the Start and Finish Time
@rem
@echo.
@echo.
for /f "tokens=5" %%A in (x:\starttime.txt) do echo Script Start Time is %%A
for /f "tokens=5" %%A in (x:\stoptime.txt) do echo Script Stop Time is %%A
@echo.
This doesn't work. It just creates a partition on the USB drive.
I have replaced the main.cmd with this text and don't works.
What's is wrong?
do not change the main.cmd in the rom
Thank you for your answer! the only way to put this files in a pendrive is with a NTFS format, but the WinPE said that not support this partition. (sorry my english and I'm desperated because I lost my IRULU windows and this is my hope).
the steps that I do are:
*Copy the files to a pendrive
*Start the IRULU w1005 with the mendrive in UEFI flash drive mode.
*a Windows command line appears and start a script, but suddenly stops with a prompt.
Maybe can help a screenshot?
yep if you can give me screenshot
Socr@tes, again..thank you for your answer! I'm uploading the images:



re
last picture show " install complete"
the call in main.cmd is nothing it's not the problem
and when you reboot what's happen
That script just take a few seconds to complete
When I reboot if I left the pendrive, runs the scripts again.
if I take off the pendrive starts my windows. (not the new windows installation).
ok
wich windows version have you on your tablet
and tell me your letter of partitions
I have windows home, and I have only one partition with letter, the "C:" with the Windows installation.
then I have 2 more partitions without letter (EFI System Partition and Recovery Partition, both without data)
I think that WinPE cannot find the main.cmd in the Pendrive, take a look at the last picture. the main.cmd file in the "scripts" folder, but in the screen says that the system cannot find.
The D letter is the pendrive, and the call is not assigned to the letter (maybe I'm wrong).
the problem is :
C= windows home
D= pendrive
so you must create another partition and after you must changing the file MBR for boot on this partition
Maybe it was wrong, but this type of installation from ROM shouldn't erase everything that was previously on the disk and generate the partitions and install windows like a new device according to the script?
the script don't erasing all data.
you've need of changing the script and adding for example that:
@rem *****************************************************************
@rem List all the disks, then search the volumes of each one to see
@rem which disks may have "Winpe" in the label. We will ignore that
@rem disk and use the first disk without the Winpe label that we find.
@rem *****************************************************************
@echo call diskpart /s %WinPESource%ListVol.txt>%WinPESource%Output.txt
diskpart /s %WinPESource%ListVol.txt>%WinPESource%Output.txt
@echo.
@echo /f "skip=8 tokens=3" %%A in (%WinPESource%Output.txt) do (if exist %%A:\images\install.txt set InstallPath=%%A:\images)
for /f "skip=8 tokens=3" %%A in (%WinPESource%Output.txt) do (
if exist %%A:\images\install.txt set InstallPath=%%A:\images
)
@echo InstallPath is "%InstallPath%"
@echo.
@echo.
@echo *****************************************************************
@echo Setting up the partition table
@echo *****************************************************************
@echo call diskpart /s %InstallPath%\wimpart.txt
diskpart /s %InstallPath%\wimpart.txt
@echo.
@echo.
@echo.
@echo *****************************************************************
@rem Map drive letter for Install.wim and Winre.wim
@echo *****************************************************************
@echo.
@rem Check InstallPath was found and there are images in it.
if NOT EXIST %InstallPath%\Install.wim echo "Install.wim NOT found." && goto :Error
@echo Install.wim FOUND at %InstallPath%\install.wim
@echo.
@rem Check that Winre.wim is there as well.
if NOT EXIST %InstallPath%\Winre.wim echo "Winre.wim NOT found." && goto :Error
@echo Winre.wim FOUND at %InstallPath%\winre.wim
@echo.
@echo.
@echo.
@echo *****************************************************************
Changing the script with your recomendation goes forward a few more steps
But cannot find the install.wim