Advertisement
ArticPolar

apply-win-image.bat

Mar 8th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2.  
  3. :FilePath-Goto
  4. set /p "FilePath=Please enter the full path name of Your Windows Image (.wim, .esd, .swm): "
  5. for /f "delims=" %%a in ("%FilePath%") do set "Extension=%%~xa"
  6. if /i "%Extension%"==".wim" (goto image-wim)
  7. if /i "%Extension%"==".esd" (goto image-esd)
  8. if /i "%Extension%"==".swm" (goto image-swm) else (echo "Selected Image is invalid!" && goto FilePath-Goto)
  9.  
  10. :image-wim
  11. DISM.exe /Get-WimInfo /WimFile:"%FilePath%" >Wininfo.txt && Wininfo.txt
  12.  
  13. set /p "WinIndex1=Please enter the Index Number of Edition: "
  14.  
  15. :Apply-Dir-Goto
  16. set /p "Apply-Dir1=Please enter the full path name of Your Apply Directory (Not C:\, Example: X:\): "
  17. cls
  18. if /i "%Apply-Dir1%"=="C:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto1)
  19. if /i "%Apply-Dir1%"=="c:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto1)
  20. if /i "%Apply-Dir1%"=="C:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto1)
  21. if /i "%Apply-Dir1%"=="c:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto1)
  22.  
  23. set /p "BootMode1=Select Boot Mode (UEFI, BIOS, ALL): "
  24. cls
  25. if /i "%BootMode1%"=="BIOS" (set bootmd1=BIOS)
  26. if /i "%BootMode1%"=="bios" (set bootmd1=BIOS)
  27. if /i "%BootMode1%"=="UEFI" (set bootmd1=UEFI)
  28. if /i "%BootMode1%"=="uefi" (set bootmd1=UEFI)
  29. if /i "%BootMode1%"=="ALL" (set bootmd1=ALL)
  30. if /i "%BootMode1%"=="all" (set bootmd1=ALL) else (echo Boot Mode Invalid! && goto BootMode-Goto1)
  31.  
  32. DISM.exe /Apply-Image /ImageFile:%FilePath% /Index:%WinIndex1% /ApplyDir:%Apply-Dir1%
  33. bcdboot %Apply-Dir1%\Windows /s %Apply-Dir1% /f %BootMode1%
  34. echo Complete Instalation!, Press any button to Close
  35. pause>nul
  36. exit
  37.  
  38. :image-esd
  39. DISM.exe /Get-WimInfo /WimFile:"%FilePath%" >Wininfo.txt && Wininfo.txt
  40.  
  41. set /p "WinIndex2=Please enter the Index Number of Edition: "
  42.  
  43. :Apply-Dir-Goto
  44. set /p "Apply-Dir2=Please enter the full path name of Your Apply Directory (Not C:\, Example: X:\): "
  45. cls
  46. if /i "%Apply-Dir2%"=="C:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto2)
  47. if /i "%Apply-Dir2%"=="c:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto2)
  48. if /i "%Apply-Dir2%"=="C:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto2)
  49. if /i "%Apply-Dir2%"=="c:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto2)
  50.  
  51. set /p "BootMode2=Select Boot Mode (UEFI, BIOS, ALL): "
  52. cls
  53. if /i "%BootMode2%"=="BIOS" (set bootmd2=BIOS)
  54. if /i "%BootMode2%"=="bios" (set bootmd2=BIOS)
  55. if /i "%BootMode2%"=="UEFI" (set bootmd2=UEFI)
  56. if /i "%BootMode2%"=="uefi" (set bootmd2=UEFI)
  57. if /i "%BootMode2%"=="ALL" (set bootmd2=ALL)
  58. if /i "%BootMode2%"=="all" (set bootmd2=ALL) else (echo Boot Mode Invalid! && goto BootMode-Goto)
  59.  
  60. DISM.exe /Apply-Image /ImageFile:%FilePath% /Index:%WinIndex2% /ApplyDir:%Apply-Dir2%
  61. bcdboot %Apply-Dir2%\Windows /s %Apply-Di2r% /f %BootMode2%
  62. echo Complete Instalation!, Press any button to Close
  63. pause>nul
  64. exit
  65.  
  66. :image-swm
  67. DISM.exe /Get-WimInfo /WimFile:"%FilePath%" >Wininfo.txt && Wininfo.txt
  68.  
  69. set /p "WinIndex3=Please enter the Index Number of Edition: "
  70.  
  71. :Apply-Dir-Goto3
  72. set /p "Apply-Dir3=Please enter the full path name of Your Apply Directory (Not C:\, Example: X:\): "
  73. cls
  74. if /i "%Apply-Dir3%"=="C:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto3)
  75. if /i "%Apply-Dir3%"=="c:" (echo "C: It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto3)
  76. if /i "%Apply-Dir3%"=="C:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto3)
  77. if /i "%Apply-Dir3%"=="c:\" (echo "C:\ It is the system disk, it is can not be used to apply the image" && goto Apply-Dir-Goto3)
  78.  
  79. :BootMode-Goto3
  80. set /p "BootMode3=Select Boot Mode (UEFI, BIOS, ALL): "
  81. cls
  82. if /i "%BootMode3%"=="BIOS" (set bootmd3=BIOS)
  83. if /i "%BootMode3%"=="bios" (set bootmd3=BIOS)
  84. if /i "%BootMode3%"=="UEFI" (set bootmd3=UEFI)
  85. if /i "%BootMode3%"=="uefi" (set bootmd3=UEFI)
  86. if /i "%BootMode3%"=="ALL" (set bootmd3=ALL)
  87. if /i "%BootMode3%"=="all" (set bootmd3=ALL) else (echo Boot Mode Invalid! && goto BootMode-Goto3)
  88.  
  89. DISM.exe /Apply-Image /ImageFile:%FilePath% /Index:%WinIndex3% /ApplyDir:%Apply-Dir3%
  90. bcdboot %Apply-Dir3%\Windows /s %Apply-Dir3% /f %BootMode3%
  91. echo Complete Instalation!, Press any button to Close
  92. pause>nul
  93. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement