搜尋此網誌

2011年10月22日 星期六

EFI Shell commands -- IF(在一個特定的狀況去執行一個或多個指令)

Executes one or more commands in specified conditions.

IF [NOT] EXIST file THEN
    command [arguments]
[ELSE
    command [arguments]]
ENDIF


IF [NOT] string1 == string2 THEN
    command [arguments]
    [command [arguments]]
    ...
[ELSE
    command [arguments]
    [command [arguments]]
    ...]
ENDIF


    EXIST file            - TRUE if file exists in the directory
    string1 == string2    - TRUE if the two stings are same

Note:
    1. The IF command is only available in batch script files.
    2. If condition is TRUE, commands between IF and ELSE will be
       executed.
    3. If condition is FALSE but keyword 'NOT' is not prefixed, commands
       between ELSE and ENDIF will also be executed.

Examples:
    #
    #  Example script for "if" command
    #
    if exist fs0:\myscript.sc then
    myscript myarg1 myarg2
    endif
    if %myvar% == runboth then
    myscript1
    myscript2
    endif

3 則留言:

  1. How to input a parameter and check its word from shell command line?
    1. make a file which name is "test.nsh".
    2. content:
    #
    # test.nsh
    #
    if %1% == yes then
    echo "output:" %1
    endif

    3: fs0:\> test.nsh yes
    output: yes

    回覆刪除
  2. 請問win command有find /c /i這個指令?UEFI有嗎?這是可以check txt內的關鍵字

    回覆刪除
  3. 目前UDK/EDK Shell Library可能沒有,要寫程式判斷。

    回覆刪除