Q. How can a script show or hide the My Documents and/or My Computer and/or My Network Places and/or Internet Explorer desktop icons?

Jerold Schulman

December 10, 2006

2 Min Read
ITPro Today logo

Using REG.EXE, built into Windows XP, Windows Server 2003, Windows Vista, and later operating systems, or installed from the Windows 2000 Support Tools, I have scripted ShowDesktopIcons.bat to show or hide the My Documents and/or My Computer and/or My Network Places and/or Internet Explorer desktop icons.

The syntax for using ShowDesktopIcons.bat is:

[call] ShowDesktopIcons MyDocuments MyComputer MyNetworkPlaces InternetExplorer

Where:

MyDocuments       - is an H to hide the My Documents icon or an S to show it.MyComputer        - is an H to hide the My Computer icon or an S to show it.MyNetworkPlaces   - is an H to hide the My Network Places icon or an S to show it.InternetExplorer  - is an H to hide the Internet Explorer icon or an S to show it.

NOTE: After running ShowDesktopIcons.bat, you must select the desktop and press F5 to refresh the display.

ShowDesktopIcons.bat contains:

@echo offIf {%4}
<h1><a name="_echo_Syntax_ShowDesktopIcons_MyDocuments_MyComputer_MyNetworkPlaces_InternetExplorer_amp_goto_EOF_setlocal_If_4_" id="_echo_Syntax_ShowDesktopIcons_MyDocuments_MyComputer_MyNetworkPlaces_InternetExplorer_amp_goto_EOF_setlocal_If_4_">{} @echo Syntax ShowDesktopIcons MyDocuments MyComputer MyNetworkPlaces InternetExplorer&amp;goto :EOFsetlocalIf {%4}</a></h1>
{} @echo Syntax ShowDesktopIcons MyDocuments MyComputer MyNetworkPlaces InternetExplorer&endlocal&goto :EOFset MyDocuments=%1set MyComputer=%2set MyNetworkPlaces=%3set InternetExplorer=%4if /i "%MyDocuments%" EQU "H" set MyDocuments=1&goto tMCif /i "%MyDocuments%" EQU "S" set MyDocuments=0&goto tMC@echo Syntax ShowDesktopIcons - My Documents NOT S or H&endlocal&goto :EOF:tMCif /i "%MyComputer%" EQU "H" set MyComputer=1&goto tMNif /i "%MyComputer%" EQU "S" set MyComputer=0&goto tMN@echo Syntax ShowDesktopIcons - My Computer NOT S or H&endlocal&goto :EOF:tMNif /i "%MyNetworkPlaces%" EQU "H" set MyNetworkPlaces=1&goto tIEif /i "%MyNetworkPlaces%" EQU "S" set MyNetworkPlaces=0&goto tIE@echo Syntax ShowDesktopIcons - My NetworkPlaces NOT S or H&endlocal&goto :EOF:tIEif /i "%InternetExplorer%" EQU "H" set InternetExplorer=1&goto tOKif /i "%InternetExplorer%" EQU "S" set InternetExplorer=0&goto tOK@echo Syntax ShowDesktopIcons - Internet Explorer NOT S or H&endlocal&goto :EOF:tOKcall :quiet >Nul 2>&1endlocalgoto :EOF:quietset CV="HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsClassicStartMenu"set XV="HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerHideDesktopIconsNewStartPanel"REG ADD %CV% /V {450D8FBA-AD25-11D0-98A8-0800361B1103} /T REG_SZ /F /D %MyDocuments%REG ADD %XV% /V {450D8FBA-AD25-11D0-98A8-0800361B1103} /T REG_SZ /F /D %MyDocuments%REG ADD %CV% /V {20D04FE0-3AEA-1069-A2D8-08002B30309D} /T REG_SZ /F /D %MyComputer%REG ADD %XV% /V {20D04FE0-3AEA-1069-A2D8-08002B30309D} /T REG_SZ /F /D %MyComputer%REG ADD %CV% /V {208D2C60-3AEA-1069-A2D7-08002B30309D} /T REG_SZ /F /D %MyNetworkPlaces%REG ADD %XV% /V {208D2C60-3AEA-1069-A2D7-08002B30309D} /T REG_SZ /F /D %MyNetworkPlaces%REG ADD %CV% /V {871C5380-42A0-1069-A2EA-08002B30309D} /T REG_SZ /F /D %InternetExplorer%REG ADD %XV% /V {871C5380-42A0-1069-A2EA-08002B30309D} /T REG_SZ /F /D %InternetExplorer%


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like