I've successfully used writesecuresetting in a legacy script to update the private_dns_mode and private_dns_specifier of phones running Android 13 and Android 14. Here's a working example:
writesecuresetting -glo private_dns_mode hostname
writesecuresetting -glo private_dns_specifier profilename.dns.nextdns.io
However, I want to write a script that periodically checks to ensure that setting is still set, and corrects it if the user changes it. Also, I want to change the DNS specifier string based on the phone name and various other settings.
I'm comfortable writing the necessary javascript logic, but I can't find a way to run writesecuresetting to change the setting. This seems like a significant oversight (either in the API design or on my part), and adding this would open all sorts of scripting possibilities.
This may be an XY problem, so feel free to point me to a better way to do this.
Edit: Just realizing this would be entirely possible if there was an API to run shell commands. That would open up all sorts of opportunities for more powerful scripting.