I have a problematic part on my batch script
echo. Some text >> %file%
if %errorlevel%==0 echo Success!
if not %errorlevel%==0 echo Fail!
If %file%
is somewhere like c:\windows\test.txt
, that makes the UAC complain
The prompt will display
Access Denied Success!
How can I work around this problems that the buffer output doesn't set an errorlevel?
I thought that I may use some command that writes to a text file instead of >>
.
I can use any command that is built in to Windows above Vista, I can't use other CMD tools.
Any other suggestion is welcome. I just need to append text and check if it was written or not.