UPDATE 2
Eh, after some (re)search, Microsoft has an official way to install winpe on a hard drive
official link: https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/winpe-install-on-a-hard-drive--flat-boot-or-non-ram
The problem with UPDATE1 is that I formatted the empty disk as ntfs, it should be fat32, and should not be too large.
I tested the official method, it boots ok.
UPDATE1:
To write winpe to a hard disk without dism++. (have some problems)
Suppose you have an empty disk p
Write the .wim image
dism.exe /apply-image /imagefile:d:\sources\boot.wim /index:1 /applydir:p:\
Make it bootable
bcdboot.exe p:\Windows /s p: /f bios
The hard disk p can boot with ubuntu grub, it will show an error, but will continue to boot normally

However, it can't boot independently, it says no bootable device.
I think this where dism++ does the trick.
I try to search if dism++ is open source, it's not. so that's it.
Earlier commment, still true:
I make a winpe virtual machine with dism++ suggested by david-p.
But beside that, winpe seems can't do too much, it's just a mini, reducted version of windows.
Most settings made in winpe are not permanent, I don't try neither, because it's not worth it.
You can't install ssh server on winpe, no telnet server neither.
No static ip address, althogh you can configure it, but it's not permanent.
Winpe is a good learning tool, at least you don't need a licence to activate.
Above all, it's very reducted, can't do too much.
boot.wim/winre.wimto a partition and add it to the BCD store viaBCDeditorBootRec /RebuildBCDfrom within WinPE. – JW0914 Jul 04 '21 at 14:55Dism /Apply-Imagetheboot.wim/winre.wimto a partition and add it as a boot entry to the BCD Store viaBCDeditorBootRec. Being concise matters. – JW0914 Jul 04 '21 at 15:13"@David.P: really, where?"
It seems you still didn't read both the question, and my yesterday's answer to it. Pls. stop doing so because this costs everyone unnecessary time.
– David.P Jul 04 '21 at 15:37