killall Dock - all active windows maximize and appear on Desktop
I know of no way to keep minimized windows from being restored when executing a killall Dock command, by any method.

The long workaround is to enumerate all application processes with visible windows and make a list of all minimized windows before executing killall Dock and then use the list to re-minimize afterwards. I seriously don't recommend doing that, but it's doable if you want to spend the time coding it.

That said, why not just use a method that doesn't require using killall Dock and immediately changes the wallpaper?

Here are two examples using AppleScript:

tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Milky Way.jpg"


Or:

tell application "Finder" to set desktop picture to alias "Macintosh HD:Library:Desktop Pictures:Sierra.jpg"


From the command line, e.g. in Terminal or shell based script:

osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/Library/Desktop Pictures/Milky Way.jpg"'


Any of these immediately changes the wallpaper without further need to do anything.