How to know which partition is Active?
#1
Posted 24 June 2009 - 12:36 PM
Any discussion in this regard is welcome.
REGARDS
MOONLIGHT SONATA
#2
Posted 24 June 2009 - 01:17 PM
#3
Posted 25 June 2009 - 12:32 AM
1. Pressed the power button
2. BIOS POST screen
3. Boot Choice Menu displayed, imagine it like below:
First harddisk, first partition
First harddisk, second partition
First harddisk, third partition
First harddisk, fourth partition
We've two options at this stage - either push one choice from the menu and when desktop loads, start diskmgmt.msc from run box and know which partition is active, or, go back by pressing ctrl+alt+del and push a PE CD, then boot the PE and there again start any compatible application to learn which is active partition.
You may agree with me, all these are workarounds to the problem, not the solution. I want to conclusively know which partition is active and what is its drive letter, before I push a script to modify boot.ini - be it to add a /kernel=somename.exe switch, or add a /hal=440volts.dll switch to bind the booting of one OS to a specific hardware abstraction layer.
I hope I explained the necessity of my thinking in this regard.
REGARDS
MOONLIGHT SONATA
#4
Posted 25 June 2009 - 07:40 AM
#5
Posted 25 June 2009 - 10:01 AM
Someone VERY VERY SPECIAL and very close to my heart both in terms of esteem and effort that he generates in me for him read my topic starter when i 1st posted it. I keep my fingers crossed. Perhaps it's my inability that i couldn't drive home the point behind this whole thinking. Sorry, mate.
thanks.
#6
Posted 25 June 2009 - 10:39 AM
Try this:
@Echo off&Setlocal For /f "skip=1 delims=" %%a In ( 'Wmic Partition Where "BootPartition=True" Get DeviceID') Do Call :GetEm %%a Echo/Booted to Partition %prt% on Disk %dsk% and assigned to Drive %drv% Goto :Eof :GetEm Set dp="%*" For /f "tokens=3,5,7 delims==#, " %%a In ( 'Wmic Path Win32_LogicalDiskToPartition Get Antecedent^, Dependent^ ^|Find %dp%') Do Set "drv=%%~c"&Set "dsk=%%a"&Set "prt=%%b)
#7
Posted 25 June 2009 - 12:01 PM
('Wmic Path Win32_LogicalDiskToPartition Get Antecedent^, Dependent^^|Find %dp%')
Output is : | is unexpected at this time.
meanwhile i'm attaching a cmd script which i made and use for adding a /hal= switch depending upon a specific HAL type. That, though a rudimentary one, still throws light why knowing active partitions' drive letter is mandatory.
Attached File(s)
-
fixbini.cmd.txt (10.88K)
Number of downloads: 7
#8
Posted 25 June 2009 - 01:20 PM
The script was actually returning the data for the Boot partition, the trouble is that in many cases there is only one boot partition, meaning that regardless of which partition you were currently booted to the result would be the same.
I will return the code as was and provide this more compact solution to return the partition and disk of the currently booted system.
@Echo off&Setlocal For /f "tokens=3,5,7 delims==#, " %%a In ( 'Wmic Path Win32_LogicalDiskToPartition Get Antecedent^, Dependent^ ^|Find "%SystemDrive%"') Do Set "drv=%%~c"&Set "dsk=%%a"&Set "prt=%%b) Echo/Booted to Partition %prt% on Disk %dsk% and assigned to Drive %drv%
#9
Posted 25 June 2009 - 09:58 PM
output for the earlier script is:
Booted to Partition 1 on Disk 0 and assigned to Drive D:
output for the last one you posted is:
Booted to Partition 0 on Disk 0 and assigned to Drive C:
What i understand with my limited knowledge is that the 1st output detects the active boot device and its assigned drive letter, while the 2nd one detects the currently booted partition. In case of a single partition system as we find in enterprises, both the output will be same.
One problem that always pinned me is that while WMI returns partitions as 0,1,2,3,...,
boot loader reads boot.ini and boots partitions on the basis of Partition(1),(2),(3),(4)... I thought about Get Antecedent and correlating with actual drive letters, but it was beyond my imagination that Get Antecedent^, Dependent could be used in a single query. I never found anything in net like that.
You are genius. It's imagination of a genius; Google can search only what is recorded in fine print, it can't guess what genius holds in his imagination.
Thanks.
REGARDS
MOONLIGHT SONATA
This post has been edited by MOONLIGHT SONATA: 25 June 2009 - 10:00 PM
#11
Posted 26 June 2009 - 12:11 PM
Disk 0 Partition 1 is active partition with letter C:
Which actually is not.
PARTSTATE.TXT contains:
SELECT DISK 0
SELECT PART 1
SELECT PART 2
SELECT PART 3
SELECT PART 4
DETAIL PART
The correct description would have to be:
Disk 0 Partition 2 is active partition with letter D:
Probing the script why it failed. inform you latter.
REGARDS
MOONLIGHT SONATA
#12
Posted 26 June 2009 - 12:32 PM
so correct Partition NO. as well as the correct drive letter will be obtained by slightly modifying your code as noted below:
:GETACTIVEPART
FOR /F "TOKENS=2" %%A IN ('DISKPART /S GETPARTNUM.TXT^|FINDSTR /I "Primary Logical"') DO (
ECHO>PARTSTATE.TXT SELECT DISK %HDNUM%
ECHO>>PARTSTATE.TXT SELECT PART %%A
ECHO>>PARTSTATE.TXT DETAIL PART
FOR /F "TOKENS=4" %%B IN ('DISKPART /S PARTSTATE.TXT^|FINDSTR /I "System"') DO SET PARTNUM=%%A&SET LETTER=%%B&GOTO :EOF
)
What you think about the static HDNUM=0?
thanks.
#13
Posted 26 June 2009 - 12:47 PM
actpart.cmd (688bytes)
Number of downloads: 14
And about static %HDNUM%... if you're using it on a installed OS simply value could be changed manually or user could be asked about what HD to check; and if used during an installing process, again user can be asked, or script could check with diskpart what's the HD of %HOMEDRIVE%, provided that you are probably tryining to modify the boot.ini of the active partition of the BIOS selected bootable HD.
I've been investigating what WMIC can get from BIOS and I couldn't find how to get the HD booting order, which maybe could help you.
This post has been edited by strel: 27 June 2009 - 02:17 PM



Help

Back to top









