Friday 19 September 2014

Write a program in C++ to make USB Device Bootable by installing required system files

To Create Bootable USB , we need to copy following files in USB.
Write a program in C++ top copy a file from Your system to USB drive.

Files Required to create a Bootable Drive :
1. CONFIG.SYS
2. SYS.COM
3. IO.SYS
4. MSDOS.SYS
5. COMMAND.SYS


On copying these files just restart your system.

We can copy more files from MSDOS system files to add more functionality.
Following is list of various MSDOS System Files that can be used to add more
functionality.

List of MS-DOS system files
MS-DOS / PC DOS and some related disk operating systems use the files mentioned here.

System Files:
• IO.SYS (or IBMBIO.COM): This contains the system initialization code and
builtin device drivers.
• MSDOS.SYS (or IBMDOS.COM): This contains the DOS kernel.

Command line interpreter (Shell):
• COMMAND.COM: This is the command interpreter.

User configuration files:
• AUTOEXEC.BAT: This is run by the default shell (usually COMMAND.COM) to
execute commands at startup.
• CONFIG.SYS: This contains statements to configure DOS and load device
drivers.

Standard DOS utility programs:
• APPEND: Set a search path for data files.
• ATTRIB: Set or display file attributes.
• BACKUP / RESTORE: simple backup and restore utilities.
• CHKDSK: Check disk for file system integrity.
• COMP / FC: File compare utilities.
• DEBUG: Simple command line debugger.
• DELTREE: Delete a directory tree.
• DISKCOMP: Compare floppy disks.
• DISKCOPY: Copy floppy disks.
• DOSKEY: Command line editor.
• EDIT / EDLIN: Very basic text editor(s); EDLIN is in earlier versions.
• FDISK: Partitions fixed disks.
• FIND: Find text in files.
• FORMAT: Formats disks.
• JOIN: Joins a drive letter to a subdirectory.
• LABEL: Set or remove a disk volume label.
• MEM: Display memory usage.
• MODE: Set modes for system devices.
• MORE: Display output one screen at a time.
• MOVE: Move files from one directory to another.
• PRINT: Print spooler.
• REPLACE: Replace files.
• SHARE: File sharing and locking support.
• SORT: Sorts input.
• SUBST: Substitutes a drive letter for a subdirectory.
• SYS: Transfers the system files to another drive to make it bootable.
• TREE: Display a directory tree.
• XCOPY: Extended file copy.
Standard DOS device drivers:
• ANSI.SYS: ANSI console driver.
• EMM386.EXE: Expanded memory manager.
• HIMEM.SYS: Extended memory manager.
• RAMDRIVE.SYS / VDISK.SYS: RAM disk; VDISK.SYS is in older versions of PC
DOS.

Download required files to a directory (eg: Documents)

Sample C++ code :

Add lines of code for remaining files.

#include<stdlib.h>
#include<iostream>
#include<fstream>
using namespace std;

int main()
{
 ofstream fpon;
 ifstream fpin;
 string line;

fpin.open("/home/Downloads/CONFIG.SYS");
fpon.open("/dev/sdb1/CONFIG.SYS");

 if(fpin.is_open())
  {
   while(getline(fpin,line))
    {
          fpon<<line;
         } //while ends
    } //if ends

 fpon.close();
 fpin.close();

    //in same way write code for reamining files , repeat above code and change
    //name of file only.

cout<<"All files copied"<<endl<<"Now device is bootable";
return 0;

}//main ends

No comments:

Post a Comment