Boot Configuration Functions Header: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(bootcfg.nsh - provides functions to manipulate the boot configration data (BCD))
 
(No difference)

Latest revision as of 23:48, 22 October 2016

The bootcfg.zip (10 KB) header file provides functions to manipulate the boot configration data (BCD).

The below example displays the current boot entry in a message box.

More examples are listed in Category:bootcfg.nsh

Please see links below for further information.

Example

; Licensed under the zlib/libpng license (same as NSIS)
 
; Unicode builds:
; x86 unicode
; makensis "-XTarget x86-unicode" script.nsi
; amd64 unicode
; makensis "-XTarget amd64-unicode" script.nsi
 
!define NAME "Boot Info"
Name "${NAME}"
Caption "${NAME}"
 
!include bootcfg.nsh
 
; Include required functions
${BOOTCFG_ConnectWMI}
${BOOTCFG_GetObject}
${BOOTCFG_OpenDefaultBcdStore}
${BOOTCFG_GetBcdObjectDescription}
 
Function .onInit
  InitPluginsDir
  ${BOOTCFG_ConnectWMI} $2 $3 $0
  ${If} $0 != 0
    StrCpy $1 $3
    StrCpy $3 ""
    StrCpy $2 ""
  ${Else}
    ${BOOTCFG_GetObject} $3 "BcdStore" $4 $0
    ${If} $0 != 0
      StrCpy $1 $4
      StrCpy $4 ""
    ${Else}
      ${BOOTCFG_GetObject} $3 "BcdObject" $5 $0
      ${If} $0 != 0
        StrCpy $1 $5
        StrCpy $5 ""
      ${Else}
        ${BOOTCFG_OpenDefaultBcdStore} $3 $4 $6 $0
        ${If} $0 != 0
          StrCpy $1 $6
          StrCpy $6 ""
        ${Else}
          ${BOOTCFG_GetBcdObjectDescription} $3 $4 $6 \
            $5 ${BOOTCFG_CURRENT_GUID} $1
        ${EndIf}
      ${EndIf}
    ${EndIf}
  ${EndIf}
 
  ${BOOTCFG_ReleaseObject} $6
  ${BOOTCFG_ReleaseObject} $5
  ${BOOTCFG_ReleaseObject} $4
  ${BOOTCFG_ReleaseObject} $3
  ${BOOTCFG_ReleaseObject} $2
 
  ${If} $0 == 0
    MessageBox MB_OK "Current boot entry: $1"
  ${Else}
    IntFmt $0 "0x%08X" $0
    MessageBox MB_OK "$1: $0"
  ${EndIf}
  Quit
FunctionEnd
 
Section
SectionEnd

Links