?
Solved

how can i make a bootable usb drive programatically

Posted on 2008-09-29
7
Medium Priority
?
1,402 Views
Last Modified: 2013-11-14
Hi experts,
I need to make a usb drive bootable using a tool, I am asking this question here as i cannot use any third party tool to do this and i need to implement this in my code in C++.
The req are: user will insert an external USB hard disk on the machine.
and when he clicks "make bootable", the tool will first format the usb disk, I will be using format.exe to format the disk, I already have the boot files ready with me (ntldr, bootfix etc with me).
If i only copy these files to the usb disk, i will not be able to boot from this usb disk because:
The MBR on the disk is not present.
So with c++ how can i write the MBR on the USB hard drive so that it will point it to the boot files on the same disk so that my USB hard disk becomes bootable.

I am sure there is a way, but i am unaware what is it.
TIA
0
Comment
Question by:LearningCpp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 8

Expert Comment

by:Anthony2000
ID: 22598802
0
 
LVL 86

Expert Comment

by:jkr
ID: 22598824
Use 'SHFormatDrive()' (http://msdn.microsoft.com/en-us/library/bb762169(VS.85).aspx) and set the following option:

SHFMT_OPT_SYSONLY
0x002. Selects the Create an MS-DOS startup disk option, creating a system boot disk.
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 22598966
I didn't check that you are doing this under Windows. But the SHFormatDrive still requires some user interaction:
from SHFormatDrive's remarks section:
"The format is controlled by the dialog interface. That is, the user must click the OK button to actually begin the formatthe format cannot be started programmatically."


0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:LearningCpp
ID: 22599504
No user interaction required, so i cannot user SHFormatDrive()?
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 22600115
Here is a link that discusses using BartPE: http://www.dedoimedo.com/computers/livecd.html See the section titled:  

"Bootable USB sticks"

0
 
LVL 17

Expert Comment

by:CSecurity
ID: 22605166
create autorun.inf in your home directory of USB memory disk that include these texts:
[autorun]
OPEN=SETUP.EXE
ICON=SETUP.EXE,0

as you know, you can change setup.exe and setup.ico as you desire
regards...
0
 

Accepted Solution

by:
LearningCpp earned 0 total points
ID: 22707491
Can i use IOCTL_DISK_SET_PARTITION_INFO and PARTITION_INFORMATION_MBR in some way to do this?

Cannot use BartPE.

which setup.exe will use autorun.inf?
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
Each year, investment in cloud platforms grows more than 20% (https://www.immun.io/hubfs/Immunio_2016/Content/Marketing/Cloud-Security-Report-2016.pdf?submissionGuid=a8d80a00-6fee-4b85-81db-a4e28f681762) as an increasing number of companies begin to…
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question