web-dev-qa-db-fra.com

Configurer les options des dossiers de l'explorateur Windows via Powershell

Je cherche un moyen de configurer quelques options dans la boîte de dialogue Options de dossier de l'Explorateur Windows via Powershell.

Les options sont:

  • Choisissez "Afficher les fichiers, dossiers et lecteurs cachés"
  • Décochez "Masquer les extensions pour les types de fichiers connus"
  • Décochez la case "Masquer les fichiers protégés du système d'exploitation (recommandé)".
38
stacker

La réponse de Keith n'a pas fonctionné pour moi hors de la boîte. La seule chose qui a entraîné la modification de la valeur du registre était ShowSuperHidden. Caché (Afficher les fichiers cachés ...) et HideFileExt (extension de fichier masqué) sont revenus à leurs valeurs précédentes dès que j'ai ouvert l'onglet Affichage dans les paramètres du dossier.

Voici ma solution, que j'ai trouvée après quelques essais et erreurs (Explorer.exe est redémarré automatiquement):

$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
Set-ItemProperty $key Hidden 1
Set-ItemProperty $key HideFileExt 0
Set-ItemProperty $key ShowSuperHidden 1
Stop-Process -processname Explorer

J'ai testé cela sur Windows Server 2008 R2 et Windows 7.

51
guyarad

Je crois que ceux-ci correspondent aux entrées de registre sous la clé de registre HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced. Vous pouvez utiliser la cmdlet Set-ItemProperty pour modifier leur valeur, par exemple:

$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced'
Set-ItemProperty $key ShowSuperHidden 1

Il semble également y avoir une clé correspondante pour la machine locale (par opposition au paramètre par utilisateur ci-dessus): HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder.

7
Keith Hill

Quelques réglages courants de l'explorateur

Windows Registry Editor Version 5.00
[hkey_current_user\software\Microsoft\windows\currentversion\Explorer\advanced]
;hide empty drives [uncheck]
"hidedriveswithnomedia"=dword:00000000
;hide extensions for known file types [uncheck]
"hidefileext"=dword:00000000
;show hidden files, folders, and drives [check]
"showsuperhidden"=dword:00000001
;hide folder merge conflicts [uncheck]
"hidemergeconflicts"=dword:00000000
;hide protected operating system files (recommended) [uncheck]
"hidden"=dword:00000001
;use check boxes to select items [check]
"autocheckselect"=dword:00000001

enregistrer sous file.reg et importer en cliquant sur ou avec reg /import (cli)

ps: aucun explorateur ni redémarrage du système requis

5
w17t

Les correctifs de registre ci-dessus sont corrects, mais ils ne résolvent pas tout le problème. Voici le script que j'utilise. Il parcourt TOUS les utilisateurs du registre et du répertoire de profils (y compris DEFAULT, afin que les utilisateurs nouvellement créés les obtiennent aussi) et définit ces options pour tous.

REM Changes to HKLM are not user-specific

REM Turns "hide file extensions" OFF and "show hidden files" ON.
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\HideFileExt /v DefaultValue /t REG_DWORD /d 0 /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL /v DefaultValue /t REG_DWORD /d 1 /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v ShowSuperHidden /t REG_DWORD /d 1 /f
REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v DontPrettyPath /t REG_DWORD /d 1 /f

REM Get path to "Users" dir.
echo WScript.Echo CreateObject("WScript.Shell").RegRead("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\ProfilesDirectory") >%temp%\profpath.vbs
for /f "tokens=*" %%i in ('cscript //nologo %temp%\profpath.vbs') do set ProfPath=%%i
del /q %temp%\profpath.vbs


REM Modifies registry keys in for all logged in users
REM Also modify it in the .DEFAULT Hive so future users get it.
REM Also edits the registry Hive for users who are not logged in
REM This section Copyright Jared Barneck
REM Modified by Ken Carlilep0 and Sam Hills

FOR /F "tokens=2* delims=\" %%a IN ('REG QUERY HKU ^|Findstr /R "DEFAULT S-1-5-[0-9]*-[0-9-]*$"') DO CALL :modkey %%a
For /d %%b in ("%ProfPath%\*") do call :modlokey "%%b"
@REM Exiting here ends the whole batch file.
EXIT /B 0


REM Modify logged-out users
:modlokey
  set RegFile=%~1\ntuser.dat
  REG LOAD HKU\TempHive "%RegFile%">NUL 2>&1
  call :modkey TempHive
  REG UNLOAD HKU\TempHive >NUL 2>&1
EXIT /B 0

REM Modifications to HKEY_USERS go here:
:modkey
REM Turns "hide file extensions" OFF and "show hidden files" ON.
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "HideFileExt" /t REG_DWORD /d "0" /f
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "Hidden" /t REG_DWORD /d "1" /f
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "ShowSuperHidden" /t REG_DWORD /d "1" /f
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "DontPrettyPath" /t REG_DWORD /d "1" /f

REM Combine taskbar buttons only when taskbar is full
REM 0 = Always combine, hide labels, 1 = Combine when taskbar is full, 2 = Never combine
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "TaskbarGlomLevel" /t REG_DWORD /d "1" /f
REM Enable this line if you use multiple monitors:
REM  REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "MMTaskbarGlomLevel" /t REG_DWORD /d "1" /f

REM Don't add "- Shortcut" to new shortcuts
REG ADD "HKU\%1\Software\Microsoft\Windows\CurrentVersion\Explorer" /v "link" /t REG_BINARY /d 00000000 /f

REM Turns on "Computer" Desktop Icon
REG ADD HKU\%1\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t REG_DWORD /d 0 /f
REG ADD HKU\%1\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu /v "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" /t REG_DWORD /d 0 /f

@REM Exiting here only ends this instance of the call to the
@REM :modkey label. It does not end the whole batch file.
EXIT /B 0
0
Sam