回显(创建)错误日志文件

时间:2023-01-25 02:07:05

I have the following lines commands:

我有以下几行命令:

if %errorlevel% equ 1 (

如果%errorlevel%equ 1(

                   set/a error=1
                   if not exist "error.log" echo. > "error.log"
                   echo the procedure has got an error >> "error.log" 
                   echo. >> "error.log
                  )

but like this I obtain the message that the file is being processed by another process.

但是像这样我得到了另一个进程正在处理文件的消息。

There is maybe another way to create the file if not exists instead of using Echo.

如果不存在而不是使用Echo,可能有另一种方法来创建文件。

1 个解决方案

#1


0  

You can create the file with

您可以使用创建文件

copy NUL error.log

However, I doubt that echo is your problem. More likely is that the file already exists and you have it opened in a text editor (or viewer) that locks the file.

但是,我怀疑回声是你的问题。更有可能的是,该文件已经存在,并且您已在文本编辑器(或查看器)中打开该文件以锁定该文件。

#1


0  

You can create the file with

您可以使用创建文件

copy NUL error.log

However, I doubt that echo is your problem. More likely is that the file already exists and you have it opened in a text editor (or viewer) that locks the file.

但是,我怀疑回声是你的问题。更有可能的是,该文件已经存在,并且您已在文本编辑器(或查看器)中打开该文件以锁定该文件。