Script: disabilitare la thumbnail cache e desktop ini
Il mio script in vbs per disabilitare la thumbnail cache e la crazione del file desktop.ini
Windows ha la spiacevole abitudine di fare vedere le miniature delle immagini nelle cartelle che le contengono e questo crea il file thumb.db in ogni cartella oppure il file desktop.ini, questi file però vengono caricati dai programmi di syncking in cloud come OneDrive o Dropbox: questo script serve a disabilitare la thumbnail cache in pc locali o remoti.
'-------------------------------------------- ' elevare i diritti da amministratore '-------------------------------------------- If WScript.Arguments.Count = 0 Then Set objShell = CreateObject("Shell.Application") objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " Run", , "runas", 1 Else '-------------------------------------------------- ' richiesta nome pc remoto, selocale usa il punto '-------------------------------------------------- 'versione script Versione = "1.0.0" strComputer = (InputBox("Inserisci nome del computer"_ & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "http://itmaniac.it" & vbTab & vbTab & vbTab & "versione " & Versione,_ "Eliminazione Thumb.db e Desktop.ini ver. " & Versione, ".")) 'intercetto click annulla if IsEmpty(strComputer) then Wscript.echo "test annullato, bye!" WScript.Quit end if ' --------- Verifica se il pc remoto è acceso tramite ping ------------- Set WshShell = WScript.CreateObject("WScript.Shell") PINGFlag = Not CBool(WshShell.run("ping -n 3 -w 2000 " & strComputer,0,True)) 'invio 3 ping al pc e aspetto risposta If strcomputer <> "." and PINGFlag = false Then 'Pc non risponde al ping Wscript.echo "Pc " & strComputer & " non risponde al ping" Else 'Pc risponde al ping, eseguo lo script Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv") strKeyPath1 = "Software\Microsoft\Windows\CurrentVersion" strKeyPath2 = "Software\Policies\Microsoft\Windows\Explorer" strKeyPath3 = "Policies\Explorer" 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath1 & "\" & strKeyPath3, "NoThumbnailCache", 1 objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath1 & "\" & strKeyPath3, "DisableThumbnailCache", 1 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath1 & "\" & strKeyPath3, "NoThumbnailCache", 1 objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath1 & "\" & strKeyPath3, "DisableThumbnailCache", 1 objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath1 & "\" & strKeyPath3, "UseDesktopIniCache", 0 objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath2, "DisableThumbsDBOnNetworkFolders", 1 strKeyPath4 = "Explorer\Advanced" 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath1 & "\" & strKeyPath4, "NoThumbnailCache", 1 objRegistry.SetDWORDValue HKEY_CURRENT_USER, strKeyPath1 & "\" & strKeyPath4, "DisableThumbnailCache", 1 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath1 & "\" & strKeyPath4, "NoThumbnailCache", 1 objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE, strKeyPath1 & "\" & strKeyPath4, "DisableThumbnailCache", 1 Wscript.echo "eseguito correttamente" end if end if WScript.Quit
Inizialmente lo script chiede di elevare i diritti UAC, poi chiede il nome del pc, localmente o remoto e poi applica le modifiche ai file di registro: in remoto funziona solo quando gli utenti sono disconnessi, quindi non loggati.
Lo script di diagnosi pc funziona se si hanno diritti di amministratore in locale e anche di dominio nel caso di pc remoti, funziona su Windows 7, 8, 8.1, 10 sia in versione 32bit che 64bit.