Solved

Boot Drive

Posted on 1997-07-11
8
295 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
[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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

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…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

628 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