Update Redirecionamento de erros + saídas normais para arquivo:
Error Output + Standard Output for filing cabinet
stderr + stdout
for filing cabinet
To hide the possessed mistakes + warnings + exits normal, but redirect these possible outputs to a file, we just point to a filing cabinet receive the redirecting of output 'stderr' to the exit 'stdout': 2>&1
== stderr > & stdout
Basically, doing the redirecting for a filing cabinet, where this will receive the exit stderr who will have his way out, in turn, too redirected to the exit stdout, thus:
commando >.\arquivo.txt strr>&stout
To test this behavior we can run a command that returns a normal output and another error return, already redirecting the error from the error output to and normal output, where we are redirecting to a.txt file.
(chcp 1252 & echo/Saída normal & copy /b 0 nul) >arquivo.txt 2>&1
The commands added in the txt file. as Normal outputs + redirected errors to the standard output:
Página de código ativa: 65001
=> of command:chcp 1252
Saída normal
=> of command:echo/Saída normal
O sistema não pode encontrar o arquivo especificado.
=> of command:copy /b 0 nul
In short, the command returns in its default output (stdout
) to the filing cabinet: arquivo.txt
, where possible output errors stderr
are being redirected to the exit stdout
.
A short commando that works both in the command line and as in the bat concealing exits, errors and warnings...
>nul chcp 65001
or >nul 2>&1 chcp 65001
Basically redirects output to dispositivo nul
no visible output from the control.
@echo off & cls & echo/
echo/exemplo 1 :: não vê nada & echo/
>nul^
(
echo/exemplo 1 :: você não vê nada
chcp 65001
dir /o0 ^< este comando gera erro^!! :: Formato de parâmetro incorreto - "0".
echo/exemplo 1 :: você continua sem ver nada^!!
) 2>nul
echo/exemplo 2 :: ve soh saida/avisos & echo/
2>nul^
(
echo/exemplo 2 :: você não vê possíveis erros mas vê as saídas
chcp 65001
dir /o0 ^< este comando gera erro^!!
echo/exemplo 2 :: e você não viu o erro do comando^!!
echo/
)
echo/exemplo 3 :: você vê somente possíveis erros & echo/
>nul^
(
echo/exemplo 3 ::: você só vê o erro
chcp 65001
dir /o0 ^< este comando gera erro^!! :: Formato de parâmetro incorreto - "0".
echo/exemplo 3 ::: e você soh ver o erro^!!
)
rem :: Ou ainda dessa forma ::
@echo off
rem :: nem erro nem saída ::
dir /o0 >nul 2>&1 ^< esse comando gera erro e você não vê o erro
dir , >nul 2>&1 ^< esse comando gera saída e você não vê
Is that all there is in the batch? If so, I think just put a /K at the end of the instruction.
– Jéf Bueno
No, there are other instructions. When you put the /K says in the cmd incorrect parameter format - /K
– Beto
Yeah, I think that would only work with one instruction only. I don’t have windows to test at the moment, but you’ve tried to give the instruction
echo off
before this line? Or maybe put>NUL
soon after the instruction you wish to silence. Just stating that I really do not remember, I am telling you everything that came to my mind, hehe.– Jéf Bueno
The " echo off" had already placed. But I didn’t know about this " > NUL ". After I put " > NUL " it worked out that unwanted messages no longer appear. Thank you.
– Beto