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
  • 5
  • 3
    Both of those shortcuts are not shown by default provided you didn't enable them when you were configuring the default user profile when you created your Windows 10 image. – Ramhound Mar 05 '18 at 16:11
  • 1
    This can also be configured via Group Policy. Are you trying to apply this setting to all newly imaged computers (use Ramhound's method and remove it from the image), or are you trying to remove it from all existing computers or a group of them in a domain environment (configure this via Group Policy) – music2myear Mar 05 '18 at 17:36
  • And knowing why you need this may help us get you a better solution. For batch you can script the import of the registry keys that make this change. – music2myear Mar 05 '18 at 17:37
  • I am trying to do this in a single computer. this is but a snippet of a bigger code. Editing Q for more details. – havakok Mar 05 '18 at 17:42
  • @havakok - I know what the question is. I was trying to point out that unless you change the default user profile, they are already removed, I was just trying to help you avoid work. So all you want to do is add custom user shortcuts, with those names, I assume you want to use the same icons? – Ramhound Mar 05 '18 at 19:08
  • @Ramhound Not necessarily shortcuts. I am generalizing to replace the original icons with either a shortcut or another batch file. you are correct to assume I want to use the same icon. – havakok Mar 05 '18 at 19:24

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.
Señor CMasMas
  • 4,794
  • 1
  • 11
  • 27
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---

Trax721
  • 1
  • 1
  • Explaining what you're doing will go a long way towards making this an answer. Currently it is just a comment. Use the EDIT button to make your answer better. – music2myear May 25 '23 at 21:58
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://superuser.com/help/whats-reputation) you will be able to [comment on any post](https://superuser.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/1191231) – music2myear May 25 '23 at 21:58
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 25 '23 at 23:08