You need to use a key in the registry.
Here is a batch file that will do exactly what you ask.
You (of course) will need to modify logic to make it your own. :-)
@echo off
Set KeyToSet=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel\
Set ThisPCGuid={20D04FE0-3AEA-1069-A2D8-08002B30309D}
Set RecycleBinGuid={645FF040-5081-101B-9F08-00AA002F954E}
:: 0 for hide and 1 for show
Set HideIconValue=0
Set ShowIconValue=1
REG ADD %KeyToSet% /v %ThisPCGuid% /t REG_DWORD /d %ShowIconValue% /f
REG ADD %KeyToSet% /v %RecycleBinGuid% /t REG_DWORD /d %ShowIconValue% /f
In case anyone is curious, I used the sysinternals process monitor to figure out what key was being affected when using the GUI to enable/disable.
The sysinternals process monitor can be frustrating trying to figure out what filters to use because no human can consume all of the information required for this task.
- Start out with a fresh filters list (there are defaults to the filters list).
- Begin eliminating/excluding things you KNOW aren't what you are looking for like ctfmon.exe, MsMpEng.exe, SearchIndexer.exe, services.exe, outlook.exe, dwm.exe, taskhostw.exe, lsass.exe, etc etc etc. It is a good idea to save this base list for the next time. Don't exclude explorer.exe, rundll32.exe, or anything that might have to deal with settings.
- Since we are looking for a registry entry, add a filter "Operation, begins with, Reg".. this will weed out anything but registry reads and writes.
- Since we are looking for a user setting, include "Path, begins with, HKCU"
- Since we know what we are looking for SUCCEEDed, right click on ANY of the SUCCESS entries and include "SUCCESS".
- Now, open the GUI that lets you toggle the icons on the desktop. You might IMMEDIATELY see the entry.. but if you don't, start checking a box, apply, uncheck a box, apply.. look for patterns in the spew. Keep weeding out things you clearly aren't looking for by registry keys.
- Eventually, with a little effort.. you will find your key. And you will get better and better at this process.