2

I want to use a batch file to add\remove System shortcuts such as "This PC" and "Recycle Bin" using a batch file. Is this possible? (Windows 8/8.1/10)

I tried this link to no avail.

The goal here is to replace the icon with another icon holding the same name which links somewhere else. I want to do this automatically on PC startup on a single machine. I cannot give more details due to corporate interest.

havakok
  • 151

2 Answers2

2

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.
0

This is an update that handled all of the items...

:: ----BEGIN----

@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} Set NetworkGuid={F02C1A0D-BE21-4350-88B0-7367FC96EF3C} Set MyFiles={59031a47-3f72-44a7-89c5-5595fe6b30ee}

:: 0 for show and 1 for hide Set IconValue=0

REG ADD %KeyToSet% /v %ThisPCGuid% /t REG_DWORD /d %IconValue% /f REG ADD %KeyToSet% /v %RecycleBinGuid% /t REG_DWORD /d %IconValue% /f REG ADD %KeyToSet% /v %NetworkGuid% /t REG_DWORD /d %IconValue% /f REG ADD %KeyToSet% /v %MyFiles% /t REG_DWORD /d %IconValue% /f

:: ---END---