Batch script to prepare Windows 7 Bootable Pendrive.

Its easy to prepare Windows 7 Bootable Pendrive if you know some commands. However, you will forget the commands and their sequence easily when you need to setup windows next time later. To overcome this problem i created a script for myself. I think it will be useful to you also.

Write the following commands to a text file and save it with .bat extension e.g PreparePendrive.bat and then right click on it and click Run as Administrator. But Beware:

  1. Keep a backup of the contents of your pendrive because it will be formatted.
  2. You have one hard disk in your computer and one pendrive. there is no other drive plugged in.

And then copy all the contents of the Windows 7 Bootable DVD to the pendrive. And Its ready to boot..

[code language=”bash”]
del DskPrtCmd.txt
REM ECHO DISKPART > DskPrtCmd.txt
ECHO LIST DISK >> DskPrtCmd.txt
ECHO SELECT DISK 1 >> DskPrtCmd.txt
ECHO CLEAN >> DskPrtCmd.txt
ECHO CREATE PARTITION PRIMARY >> DskPrtCmd.txt
ECHO SELECT PARTITION 1 >> DskPrtCmd.txt
ECHO ACTIVE >> DskPrtCmd.txt
ECHO FORMAT FS=NTFS QUICK >> DskPrtCmd.txt
ECHO ASSIGN >> DskPrtCmd.txt
ECHO EXIT >> DskPrtCmd.txt

diskpart /s DskPrtCmd.txt
del DskPrtCmd.txt
pause
[/code]

Or if you are too lazy, download it from here: https://github.com/khairulhasanmd/Prepare-Win7-Bootable-Pendrive

Leave a Reply

Your email address will not be published. Required fields are marked *