我需要在每次关闭或重新启动计算机时进行计数。因此,我相信我可以通过将批处理文件添加到开始菜单来完成此操作。因此,每次您打开 PC 时,它都会运行。当它运行时应该
open c:\count.txt
read in the value on that text file
add 1 to it
write the value to the text file
exit.
Run Code Online (Sandbox Code Playgroud)
但我没有太多使用批处理文件,并且不知道如何从文本文件中读取数字。
根据您的想法(更新文件中的计数器):
rem open c:\count.txt
rem read in the value on that text file
set /p count=<c:\count.txt
rem add 1 to it
set /a count+=1
rem write the value to the text file
>c:\count.txt echo.%count%
rem exit.
exit
Run Code Online (Sandbox Code Playgroud)
注意:请注意,您选择的路径是用户具有写入权限的路径。(C:\没有权限可能无法工作)