Solved

how can i make a bootable usb drive programatically

Posted on 2008-09-29
7
1,383 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
Concerto Cloud Services, a provider of fully managed private, public and hybrid cloud solutions, announced today it was named to the 20 Coolest Cloud Infrastructure Vendors Of The 2017 Cloud  (http://www.concertocloud.com/about/in-the-news/2017/02/0…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

729 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