RefusePS is a PowerShell-based Windows bootable USB creator.
It prepares a USB drive, formats it as FAT32, mounts a Windows ISO, copies the installer files, and automatically splits install.wim when required for FAT32 compatibility.
- Safely lists available USB disks before wiping
- Requires manual disk selection
- Requires explicit
ERASEconfirmation before destructive actions - Creates a GPT/FAT32 USB installer for UEFI systems
- Mounts Windows ISO automatically
- Copies Windows setup files using
robocopy - Splits large
install.wimfiles into.swmfiles using DISM - Supports ISOs containing either:
sources/install.wimsources/install.esd
- Dismounts ISO after completion
- Attempts to eject USB after completion
This script will erase the selected USB disk. Use it carefully.
Before running RefusePS:
- Remove USB drives you do not want to wipe
- Double-check the disk number
- Make sure the ISO path is correct
- Run PowerShell as Administrator
The author is not responsible for data loss caused by selecting the wrong disk.
- Windows 10 or Windows 11
- PowerShell 5.1 or newer
- Administrator privileges
- A Windows ISO file
- A USB drive, preferably 8 GB or larger
- UEFI-capable target system
Clone the repository:
git clone https://github.com/YOUR_USERNAME/RefusePS.git
cd RefusePSEdit the ISO path inside RefusePS.ps1:
$isoImage = "C:\Path\To\windows10.iso"Run PowerShell as Administrator.
Then execute:
.\RefusePS.ps1The script will show detected USB disks:
Number FriendlyName SerialNumber Size PartitionStyle
------ ------------ ------------ ---- --------------
1 SanDisk USB Drive XXXXXXXX 16GB MBR
Enter the correct USB disk number.
To confirm wiping the disk, type:
ERASE
RefusePS will then create the bootable USB installer.
FAT32 is used because it is widely supported by UEFI firmware. However, FAT32 has a single-file size limit of 4 GB. Many Windows ISO files include an install.wim file larger than 4 GB.
RefusePS handles this by splitting install.wim into smaller .swm files:
install.swm
install2.swm
install3.swm
Windows Setup supports this split-image format.
RefusePS uses GPT partitioning by default. This is suitable for modern UEFI-based systems. If you need Legacy BIOS boot support, GPT/FAT32 may not be enough. In that case, you may need to modify the script to use MBR instead.
RefusePS performs the following actions:
- Checks that the ISO exists
- Lists detected USB disks
- Asks the user to select the target USB disk
- Requires confirmation before wiping
- Clears the selected USB disk
- Initializes it as GPT
- Creates a FAT32 partition
- Mounts the Windows ISO
- Copies ISO contents to the USB drive
- Excludes
install.wimandinstall.esdduring the first copy - Splits
install.wimif found - Copies
install.esdif found and under 4 GB - Dismounts the ISO
- Attempts to eject the USB drive
RefusePS avoids wiping every USB disk automatically. Unlike unsafe one-liners such as:
Get-Disk | Where BusType -eq 'USB' | Clear-DiskRefusePS forces the user to select one USB disk and confirm the operation.
Still, the script is destructive. If you choose the wrong disk, the data will be erased.
Run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy BypassThen run:
.\RefusePS.ps1This only changes the execution policy for the current PowerShell session.
Robocopy exit codes below 8 usually mean success or partial success.
RefusePS treats exit codes 8 and above as failure.
Check that:
- The ISO is mounted correctly
- The USB drive is writable
- The USB drive has enough space
Make sure you are running PowerShell as Administrator.
Also verify that the Windows ISO is not corrupted.
Check the following:
- Target machine supports UEFI boot
- Secure Boot settings are compatible with the ISO
- USB boot is enabled in firmware settings
- The USB drive is selected from the boot menu
- The ISO is a valid Windows installation ISO
RefusePS is provided as-is.
You are responsible for verifying the selected disk before continuing.
Always back up important data before using disk formatting or disk wiping tools.
Harith Dilshan (h4rithd.com)