Solved

Boot Drive

Posted on 1997-07-11
8
276 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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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
 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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 opening and writing to files 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.

785 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