It should be possible, yes.
Obtain an "hybrid ISO", which is simultaneously a valid image for a non-CD drive. This will be the case for any recently produced bootable linux ISO.
Here's how to verify this before you try:
$ file -k lubuntu-12.10-alternate-i386.iso
lubuntu-12.10-alternate-i386.iso: # ISO 9660 CD-ROM filesystem data 'Lubuntu 12.10 i386 ' (bootable)\012- x86 boot sector; partition 1: ID=0x17, active, starthead 2, startsector 64, 1319448 sectors, code offset 0xed
The ISO bit tells you it's an ISO :). The x86 boot sector bit tells you that it's potentially bootable as a non-CD disk as well. (It seems to have come out all on one line for some reason). You need the -k
option of file
, or it'll stop after finding the ISO bit and won't tell you about the x86 boot sector.
(You could do also do this on a partial download of, I guess, the first 4MB of the file. In case your bandwidth is an issue).
Say goodbye to any data on the pen drive.
Carefully identify the device node for the pen drive. Try plugging it in, and see what dmesg|tail
calls it. If you have a GUI you could use that to mount it, and then have a look at the output of mount
. You're looking for something like sdx
. sda
is probably your first hard drive - don't get confused, or you'll have to say goodbye to all the data on that.
Now make sure you haven't mounted an existing filesystem on the pen drive. A modern GUI like GNOME may have mounted it when you inserted it. Look at the output of mount
again and act accordingly e.g. umount /dev/sdx1
.
dd if=lubuntu-12.10-alternate-i386.iso of=/dev/sdx bs=4k
. Replacing sdx
with the device name determined in step 3 :).
Some people try to make it go faster with e.g. bs=1M
. Personally I prefer to let the kernel sort that out. bs=4k
is a sensible minimum though; it's usually faster than the default 512 bytes, and rarely slower.
Note that the latest upstream version of the gnome-disks GUI should have a "restore disk image" feature equivalent to the above dd command. This would probably be my recommendation going forward. It should show usb drives with a nice friendly icon, and it should avoid any chance of overwriting a hard drive containing mounted filesystem(s). (You'd still need to avoid your not-mounted Windows disk though).
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
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.
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>
.
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
.
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.
Best Answer
Current best method:
Since some year, practically all of the distributions have a bootable ISO image. It results, you can simply write out the ISO to the USB device, and it will boot:
Of course double-check if you gave to correct block device.
Old method, only for Windows client machines:
Download the iso image of your most beloved linux distribution (if there isn't any, I suggest you ubuntu). They are freely downloadable from their homepage.
Download the tool named unetbootin for windows.
This unetbootin can write an iso image to an usb pendrive.
After you booted ubuntu from the pendrive, you can freely call a terminal program, or with ctrl/alt/f2 can you switch to command line console mode.
Good luck!