Solved

Boot Drive

Posted on 1997-07-11
8
257 Views
Last Modified: 2008-03-06
I would like to know exactly how to determine the boot drive of a PC. I need to locate the proper Autoexec.bat file which would be in the root directory of the boot drive. How do I determine the boot drive?
0
Comment
Question by:stickney
8 Comments
 
LVL 1

Expert Comment

by:8051
ID: 1252083
The boot procedure defined in on-board BIOS. If your BIOS
hasn't option to use ANY drive to boot - you have to select
drive C to boot and *WRITE YOUR-OWN BOOT SECTOR* on C for
switch to another drive. If you do not want to write it -
by a boot dispatcher, there are a lot of programs like this
on the market and, I think, I saw some shareware.

0
 

Author Comment

by:stickney
ID: 1252084
What I'm really looking for is how programatically (using C or C++) determine the boot drive of ANY PC (the drive their system was booted from). If possible, I would like to see some sample code. Thanks.
0
 
LVL 1

Expert Comment

by:8051
ID: 1252085
You have to rewrite on-chip BIOS to select a boot sector
will be loaded first or rewrite boot sector on first bootable
partition (see FDISK) to *CONTINUE* high level booting
(OS I/O system). Both things must be implemented in
assembler.


0
 
LVL 1

Expert Comment

by:TKII
ID: 1252086
Maybe somebody can help you if you tell what computer, operating system and language you are using.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 2

Accepted Solution

by:
sprinkmeier earned 100 total points
ID: 1252087
Autoexec.bat implies you're using DOS.
As far as I know, Dos boot from the first primary parition on the first physical disk, which is allways C:
(once you have booted up, of course)

Are you trying to determine the boot drive before or after you have booted up?
If it' after, the answer is 'C:' (else you could try interogating the PATH environement variable for x:\DOS. not fool proof, but should work 99% of the time)
If it's before, you may not be able to tell 'cos of things like BootManager.

0
 
LVL 1

Expert Comment

by:8051
ID: 1252088
After the computer booted it is too late
to determine boot drive. Autoexec.bat started
after the DOS loaded. Only 2 ways:
1. Use BOOTMANAGER
2. Rewrite BOOTSECTOR (BOOTMANAGER do it!)
   or BIOS (very dangerous!)

Regards


0
 

Author Comment

by:stickney
ID: 1252089
I'm trying to determine where the boot drive is after I have booted up. I appreciate all of your input. I thought that there must be a way to derive this information. Within InstallShield there is a command which will return the Boot drive. It makes me wonder how they determine the boot drive.
0
 
LVL 1

Expert Comment

by:mosfet
ID: 1252090
The easiest way to determine which is the boot drive is to read the partition table for the drives. The partition table is one sector in size. It has four partition entries. If 0 is the starting offset in memory for the partition table, each entry is 10h bytes in size, being at 1BEh,1CEh,1DEh,and 1EEh. At the first byte of these four offsets is the boot flag. The boot flag is 80h if it is bootable, otherwise it is 0h. Hope this answers your question. Sorry you have to do so much low level disk stuff, its the only way I know, email me if you need further explanation.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now