SCCM 2007 : VBS: How to detect windows partition and winre (or bitlocker) partition if you are in WinPE into TS
You are in WinPE....
Windows partition is not always C:, because if you do a refresh with a winre partition, winpe will assign C: to this partition but windows is not there.
So you have to determine, always, where is C:
Yes, it could be "#disk 0 #partition 2", but you could be in an architecture with data on a second partition => Résult: 3 partitions....
So, i give you a script to always find windows partition by reading bcdedit (thank you William for this idea) an dso always find windows:
copy/past it to a vbscript.vbs and run, it will create for you in your TS a variable OSDRIVE, like OSDRIVE="C:"
scriptfolder=left(WScript.ScriptFullName,len(WScript.ScriptFullName)-len(WScript.ScriptName)-1)
sCmd = "%comspec% /c bcdedit /v /enum all"
set iRetVal = oShell.Exec(sCmd)
oCheck = iRetVal.StdOut.ReadAll
Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
ProgressUI.CloseProgressDialog
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each Line In Split(oCheck,vbCrLf)
if trim(Line)="" _
or ubound(split(Line,"-------------------")) < 1 then
else
For Each Blocks In Split(oCheck,"-------------------")
If instr(Blocks,"Windows 7")>0 then
If instr(Blocks,"Winre.wim")>0 then
else
demiblock = Split(Blocks,"partition=")(1)
OSDRIVE = left(demiblock,2)
oEnvTS("OSDRIVE") = OSDRIVE
end if
end if
Next
end if
Next
Now if you want to know what is your winre partition, if it is hide. and if you define it to 1Go or "1000 M".
copy/past it to a vbscript.vbs and run, it will create for you in your TS a variable BDEPARTITION, like BDEPARTITION="partition 2"
Do it:
scriptfolder=left(WScript.ScriptFullName,len(WScript.ScriptFullName)-len(WScript.ScriptName)-1)
check_maintenancefile()
sCmd = "%comspec% /c diskpart /s " & scriptfolder & "\check_maintenance.txt"
set iRetVal = oShell.Exec(sCmd)
oCheck = iRetVal.StdOut.ReadAll
Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
ProgressUI.CloseProgressDialog
For Each Line In Split(oCheck,vbCrLf)
if trim(Line)="" _
or ubound(split(Line,"Partition")) < 1 then
else
If instr(Line,"1000 M")>0 then
oEnvTS("BDEPARTITION")=trim(mid(Line,3,11))
end if
end if
Next
sub check_maintenancefile()
dim objFSO,objTextFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(scriptfolder & "\check_maintenance.txt", ForWriting, True)
objTextFile.WriteLine("Select Disk 0")
objTextFile.WriteLine("Detail Disk")
objTextFile.Close
end sub
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article