本帖最後由 阿達金田一 於 2020-1-2 17:50 編輯
建立一個 set.txt ...用 unicode
注意 %1 後面還有一個空格
這裡我發現 > 和 >> 好像用 UNICODE 比較不會出問題
如果 >> 時...outfile 是 ASCII 有時就會無法寫入
然後 set date 看新加的 # set date 那段
比較費工...基本上 copy 一份 set.txt 為 set-tmp.nsh
然後 set-tmp.nsh 檔案的產生日期...正常應該是 copy 時 的 日期時間
用 ls -sfo 輸出 格式檔 ... set-tmp.sfo
再用 parse 取出 set-tmp.sfo 中的 date資料 追加寫入到 set-tmp.nsh 後面
然後用 set-tmp.nsh date 去 set date
會用 sfo 是因為
date 指令...的格式是 01/01/2020
檔名不能有 /
而 sfo 格式 是 01.01.2020
[Bash shell] 純文本查看 復制代碼 @echo -off
# Set Startup delay time for 0 sec
set StartupDelay 0
# Check Counter
if not IsInt(%Counter%) then
set Counter 1
goto Leave_For1
endif
for %a run (%Counter% 1%Counter%)
if %Counter% ne %a then
set Counter %a
goto Leave_For1
endif
endfor
:Leave_For1
if %Counter% lt 1 then
set Counter 1
endif
# Check and cd startup.nsh path
for %b in fs0 fs1 fs2 fs3 blk0 blk1 blk2 blk3
if exist %b:\startup.nsh then
%b:
cd\
goto Leave_For2
endif
endfor
:Leave_For2
# set date
cp set.txt set-tmp.nsh > NUL
ls -sfo set-tmp.nsh >> set-tmp.sfo
parse set-tmp.sfo FileInfo 7 -i 1 >> set-tmp.nsh
set-tmp.nsh date
del set-tmp.sfo > NUL
del set-tmp.nsh > NUL
# Set Log File
set Log startup.nsh.%date%.log
echo =========== >> %Log%
echo Boot Coutner = %Counter%
echo Boot Coutner = %Counter% >> %Log%
echo Current Working Directory = %cwd%
echo Current Working Directory = %cwd% >> %Log%
date >> %Log%
time >> %Log%
echo " " >> %Log%
echo === PCI === >> %Log%
pci >> %Log%
echo " " >> %Log%
#Wait for 3 sec then system warm reboot
stall 3000000
reset -w
另外如果
# Check and cd startup.nsh path
那段真的搞不定
其實一行一行分開寫也是可以啦...用 for 只是比較精簡
[Bash shell] 純文本查看 復制代碼 if exist fs0:\startup.nsh then
fs0:
goto Leave_For2
endif
if exist fs1:\startup.nsh then
fs1:
goto Leave_For2
endif
if exist fs2:\startup.nsh then
fs2:
goto Leave_For2
endif
:Leave_For2
cd\
|