Windows PE 批处理脚本运行,但不更新文件



我编写了一个位于 USB 软盘驱动器上的批处理脚本 (A:)称为 POSTcounter,它由 Windows PE 映像中的修改 (startnet.cmd) 文件自动执行。该脚本只是递增一个值,即帖子数,并将该数字写入保存在软盘驱动器上的 txt 文件。此脚本在 Windows 环境命令提示符下运行良好,并保存 txt 文件。但是,当脚本在 WinPE 中自动执行时,脚本会运行,但 txt 文件不会更新。

startnet.cmd 包括:

维派尼特

A:\POSTcounter.cmd

POSTcounter.cmd 包括:

@echo off
echo. This script is counting the # of POSTs.
echo.                                        

call:myPOSTTest
for /f "tokens=* delims=" %%x in (TEST.txt)  do echo POST# %%x

echo.&pause&goto:eof

::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
-- 
:myPOSTTest    - here starts my function identified by its label
cd "A:"
if not exist TEST.txt >TEST.txt echo 0
for /f %%x in (TEST.txt) do (
set /a var=%%x+1
)

>TEST.txt echo %var%
goto:eof

默认情况下,cd 函数不会更改驱动器。 所以这行:

cd "A:"

不做任何有用的事情。 尝试

cd /d a:

相反。

最新更新