How to make bootable command prompt in USB ? (cmd.iso)

batch filebootcmd.exeiso-image

I like to run command prompt or batch file in usb pendrive like Bootable os.

I had a file file.bat , which contains,

net user %username% reset password

i want to run without getting into windows OS.
Mean, from my guess it can be possible only while before booting OS. So, like windows installation iso, i hope cmd.iso too possible.

If yes, please help me guys. I hope you understood my Question.

Note : Googling with this topic only i can able to find bootable USB via cmd. But, pls note, I don't need how to boot usb via cmd. I need cmd in bootable USB.

I want to run file.bat as OS.

Best Answer

It seems you want access to a command prompt before the login screen of Windows. It also seems like you want to run a batch script with it to reset the login credentials of a profile. Even if I am wrong about the latter you will be satisfied enough with the former.

First and foremost, it is not possible to run a batch script outside of Windows, outside of CMD; the best you can do is before login during startup.

Let's create 2 batch scripts for our purposes (since you seem consistent on batch scripts today, you can also run these individually by line if you wish). If you have access to a Windows Administrator account you should create part1a.bat; if not, you need to create part1b.bat. You will create part2.bat in both cases.

part1a.bat - Use this if you can log in to an admin profile

reg add HKLM\SYSTEM\Setup /v SetupType /t REG_DWORD /d 2 /f
reg add HKLM\SYSTEM\Setup /v CmdLine /t REG_SZ /d "cmd.exe" /f
exit

part1b.bat - Use this if you cannot

REM Replace drive F: with whatever drive the main OS is on
reg load HKLM\TempHive213 F:\Windows\System32\config\SYSTEM
reg add HKLM\TempHive213\Setup /v SetupType /t REG_DWORD /d 2 /f
reg add HKLM\TempHive213\Setup /v CmdLine /t REG_SZ /d "cmd.exe" /f
exit

part2.bat - (modify this to your liking, but keep top 2 lines)

reg add HKLM\SYSTEM\Setup /v SetupType /t REG_DWORD /d 0 /f
reg add HKLM\SYSTEM\Setup /v CmdLine /t REG_SZ /d "" /f
REM Replace the user info below to what you want.
net user %username% %newpassword%
exit
  1. If you have access to a live Windows administrator account then run part1a.bat with Admin privileges and skip to step 4; if you do not, proceed to step 2.

  2. Boot to the Windows Installation ISO. Choose "Repair your PC" or "Repair your computer." Click "Command Prompt." Now you need to know the driver letters to do so you may use diskpart. Run diskpart and run list vol. Every drive should have been assigned a driver letter; if not, you can do so yourself by running these two consecutively: select vol <num> and assign letter=<letter>.

  3. If you need to reassign the driver letter to the batch script do so by running notepad D:\part1b.bat (replace the letter respectively and to its location) then modifying it, then saving it. Then run D:\part1b.bat.

  4. Restart the computer. Once restarted, during or after the Windows Boot Logo and before you ever get to the Windows Log In screen a CMD prompt with Admin privileges will appear. Use diskpart again to differ what drive is which and then run D:\part2.bat. If you haven't already please replace the line describing replacing the user credentials with the ones you want, by running notepad D:\part2.bat. If you did use the original part2.bat I specified it would set a password.

Note: diskpart may not tell you exactly which is which, you may have to try using the cd /d F: (replace letter) and dir in combination to figure out which drive is which.

Related Question