pretty code

2018年8月24日 星期五

startup.nsh in UEFI Shell

UEFI Shell 下有一個開機自動執行 tool 的方式,其方式類似 DOS 的 AUTOEXEC.BAT,只是檔名為 startup.nsh

底下是 UEFI Shell Spec 2.2 的說明:

When executing startup.nsh, the shell will search for it first in the directory where the shell itself was launched. If it cannot find the startup.nsh file in that directory or it was not launched from a file system, it will search the execution path defined by the environment variable PATH.
 
由上可以得知,正常放進 USB 裡的 Shell 會位於 EFI\BOOT\,故只要將 startup.nsh 置於此處便可以自動執行。

另外,則是要看 PATH 環境變數是否有定義,Shell 會去裡面對應的位置去尋找 startup.nsh 來執行。

這也解釋了為什麼有些電腦 startup.nsh 不放在 EFI\BOOT\ 便不會自動執行,那是因為系統並沒有 PATH 的變數存在。

沒有留言: