Powershell Use this batch command or batch script in the command prompt to clear a text file blank in Windows using the command line. The function ERROR_FUNC does not exist and this throws a blank output towards the file in the parameter below. This should work for any kind of output format.

SET XML ="%CD%\Pathtofile"

The code is best used for clearing log files without the need for VBScript or CScript. Here’s sample code below clearing an XML log file:

SET XML=%CD%\Project\Contents\Main\components.vxml
@ECHO Clearing %XML%\

@ECHO Writing file %XML%
    @ECHO ^<?xml version=^"1.0^" encoding=^"utf-16^"?^>
    @ECHO ^<components xmlns:xsi=^"http://www.w3.org/2001/XMLSchema-instance^" xmlns:xsd=^"http://www.w3.org/2001/XMLSchema^"^>
    @ECHO ^</components^>
) >>"%XML%"

@ECHO Done