Question: Is it possible to save a text file in UTF-8 encoding using Windows' command line `cmd.exe`?

Current I'm creating the text file using command redirection operators:

```
C:\Windows\system32\ipconfig /all >> output.log

```

I start with `>` to get a new file and then I use `>>` to append more information.

Answer: 
The default encoding for command prompt is Windows-1252. Change the code page (chcp command) to 65001 (UTF-8) first and then run your command. 

```
chcp 65001
C:\Windows\system32\ipconfig /all >> output.log

```

Change it back to default when done.

```
chcp 1252

```
As the existing answer says, in a batch file, you can use the [`chcp` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/chcp)

```
chcp 65001 > nul
some_command > file

```

---

But if you are using the [`cmd.exe`](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) from its command line, e.g. to execute a user-defined command, you can use this syntax:

```
cmd.exe /c chcp 65001 > nul & cmd.exe /c some_command > file

```