11080 » 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? (11-Dec-06)
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 off
If {%4}=={} @echo Syntax ShowDesktopIcons MyDocuments MyComputer MyNetworkPlaces InternetExplorer&goto :EOF
setlocal
If {%4}=={} @echo Syntax ShowDesktopIcons MyDocuments MyComputer MyNetworkPlaces InternetExplorer&endlocal&goto :EOF
set MyDocuments=%1
set MyComputer=%2
set MyNetworkPlaces=%3
set InternetExplorer=%4
if /i "%MyDocuments%" EQU "H" set MyDocuments=1&goto tMC
if /i "%MyDocuments%" EQU "S" set MyDocuments=0&goto tMC
@echo Syntax ShowDesktopIcons - My Documents NOT S or H&endlocal&goto :EOF
:tMC
if /i "%MyComputer%" EQU "H" set MyComputer=1&goto tMN
if /i "%MyComputer%" EQU "S" set MyComputer=0&goto tMN
@echo Syntax ShowDesktopIcons - My Computer NOT S or H&endlocal&goto :EOF
:tMN
if /i "%MyNetworkPlaces%" EQU "H" set MyNetworkPlaces=1&goto tIE
if /i "%MyNetworkPlaces%" EQU "S" set MyNetworkPlaces=0&goto tIE
@echo Syntax ShowDesktopIcons - My NetworkPlaces NOT S or H&endlocal&goto :EOF
:tIE
if /i "%InternetExplorer%" EQU "H" set InternetExplorer=1&goto tOK
if /i "%InternetExplorer%" EQU "S" set InternetExplorer=0&goto tOK
@echo Syntax ShowDesktopIcons - Internet Explorer NOT S or H&endlocal&goto :EOF
:tOK
call :quiet >Nul 2>&1
endlocal
goto :EOF
:quiet
set CV="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu"
set XV="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
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%
End of Article

