Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- Title Show Or Hide Desktop Icons And Show Or Hide Seconds In System Clock
- Color 9E & Mode 82,12 & SetLocal EnableDelayedExpansion
- Call:CreateShortcut
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- :: Automatically check & and start the batch file with admin rights
- (Net session >nul 2>&1)||(PowerShell start """%userprofile%\Desktop\%~n0.lnk""" -verb RunAs & Exit /B)
- ::--------------------------------------------------------------------------
- Set "Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
- ::--------------------------------------------------------------------------
- :GetInfo
- @REM Get Opened Folders with PowerShell code in a batch file
- Set PSCommand="@((New-Object -com shell.application).Windows()).Document.Folder | ForEach { $_.Self.Path }"
- REM Populate the array with existent and opened folders
- SetLocal EnableDelayedExpansion
- Set /a Count=0
- for /f "delims=" %%a in ('Powershell -C %PSCommand%') do (
- Set /a Count+=1
- Set "Folder[!Count!]=%%a"
- )
- ::===========================================================================
- :menuLOOP
- ::===========================================================================
- echo(
- echo(
- echo( ***************************** Menu ******************************
- echo(
- @for /f "tokens=2* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do (
- echo( %%A %%B)
- echo(
- echo( *****************************************************************
- echo( &Set /p Selection=Make a Selection or hit ENTER to quit: || Goto :EOF
- echo( & Call:menu_[%Selection%]
- GOTO:menuLOOP
- ::===========================================================================
- ::---------------------------------------------------------------------------------------------------
- :menu_[1] Show Seconds In SystemClock
- reg Add "%Key%" /V ShowSecondsInSystemClock /T REG_DWORD /D 1 /F 1>NUL
- Call:Restart_Explorer
- @rem Restore all closed folders
- @for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
- :menu_[2] Hide Seconds In SystemClock
- reg Add "%Key%" /V ShowSecondsInSystemClock /T REG_DWORD /D 0 /F 1>NUL
- Call:Restart_Explorer
- @rem Restore all closed folders
- @for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
- :menu_[3] Hide Desktop Icons
- reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDesktop /t REG_DWORD /d 1 /f 2>nul
- Call:Restart_Explorer
- @rem Restore all closed folders
- @for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
- :menu_[4] Show Desktop Icons
- reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer /v NoDesktop /f 2>nul
- Call:Restart_Explorer
- @rem Restore all closed folders
- @for /L %%i in (1,1,%Count%) do Start /MAX Explorer "!Folder[%%i]!"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
- :Restart_Explorer
- Powershell -C "gps explorer | spps"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
- :CreateShortcut
- Powershell ^
- "$s=(New-Object -COM WScript.Shell).CreateShortcut('%userprofile%\Desktop\%~n0.lnk'); ^
- $s.TargetPath='%~f0'; ^
- $s.WorkingDirectory='%~dp0'; ^
- $s.IconLocation='colorcpl.exe,0'; ^
- $s.HotKey='CTRL+ALT+I'; ^
- $s.Save()"
- Exit /B
- ::---------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment