It sounds like you want to send all wallet funds in a single-line command.
In a Unix shell, this should work:
bitcoin-cli sendtoaddress <address> $(bitcoin-cli getbalance) "" "" true
The Windows command prompt doesn't support the substitution via backticks or $(…), but I'm reading that you should be able to use a
FOR /F loop with the
usebackq option to emulate it:
for /F "usebackq delims=" %A in (`bitcoin-cli getbalance`) do bitcoin-cli sendtoaddress <address> %A "" "" true
I have no Windows machine and have not tested this, I suggest you verify carefully and use at own risk.
Starting with the next release, Bitcoin Core v24, you will be able to use
bitcoin-cli sendall '["<address>"]' null "unset" <feerate (s/vB)>