' Version 1.3 main sub main() On Error Resume Next Set WshShell = WScript.CreateObject("WScript.Shell") Set fs = CreateObject("Scripting.FileSystemObject") sysfolder = fs.GetSpecialFolder(1) & "\" ind = 0 ''''''' DisableRegistryTools call Rw("HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableRegistryTools", "0", "REG_DWORD", ind) ''''''' file .bat If (Rr("HKCR\.bat\") <> "batfile") Then call Rw("HKCR\.exe\", "batfile", "", ind) End If If (Rr("HKCR\batfile\shell\open\command\") <> """%1"" %*") Then call Rw("HKCR\batfile\shell\open\command\", """%1"" %*", "", ind) End If If (Rr("HKLM\Software\CLASSES\.bat\") <> "batfile") Then call Rw("HKLM\Software\CLASSES\.bat\", "batfile", "", ind) End If If (Rr("HKLM\Software\CLASSES\batfile\shell\open\command\") <> """%1"" %*") Then call Rw("HKLM\Software\CLASSES\batfile\shell\open\command\", """%1"" %*", "", ind) End If ''''''' file .com If (Rr("HKCR\.com\") <> "comfile") Then call Rw("HKCR\.exe\", "comfile", "", ind) End If If (Rr("HKCR\comfile\shell\open\command\") <> """%1"" %*") Then call Rw("HKCR\comfile\shell\open\command\", """%1"" %*", "", ind) End If If (Rr("HKLM\Software\CLASSES\.com\") <> "comfile") Then call Rw("HKLM\Software\CLASSES\.com\", "comfile", "", ind) End If If (Rr("HKLM\Software\CLASSES\comfile\shell\open\command\") <> """%1"" %*") Then call Rw("HKLM\Software\CLASSES\comfile\shell\open\command\", """%1"" %*", "", ind) End If ''''''' file .exe If (Rr("HKCR\.exe\") <> "exefile") Then call Rw("HKCR\.exe\", "exefile", "", ind) End If If (Rr("HKCR\exefile\shell\open\command\") <> """%1"" %*") Then call Rw("HKCR\exefile\shell\open\command\", """%1"" %*", "", ind) End If If (Rr("HKLM\Software\CLASSES\.exe\") <> "exefile") Then call Rw("HKLM\Software\CLASSES\.exe\", "exefile", "", ind) End If If (Rr("HKLM\Software\CLASSES\exefile\shell\open\command\") <> """%1"" %*") Then call Rw("HKLM\Software\CLASSES\exefile\shell\open\command\", """%1"" %*", "", ind) End If ''''''' file .hta If (Rr("HKCR\.hta\") <> "htafile") Then call Rw("HKCR\.exe\", "htafile", "", ind) End If If (Rr("HKCR\htafile\shell\open\command\") <> sysfolder & "MSHTA.EXE ""%1"" %*") Then call Rw("HKCR\htafile\shell\open\command\", sysfolder & "MSHTA.EXE ""%1"" %*", "", ind) End If If (Rr("HKLM\Software\CLASSES\.hta\") <> "htafile") Then call Rw("HKLM\Software\CLASSES\.hta\", "htafile", "", ind) End If If (Rr("HKLM\Software\CLASSES\htafile\shell\open\command\") <> sysfolder & "MSHTA.EXE ""%1"" %*") Then call Rw("HKLM\Software\CLASSES\htafile\shell\open\command\", sysfolder & "MSHTA.EXE ""%1"" %*", "", ind) End If ''''''' file .pif If (Rr("HKCR\.pif\") <> "piffile") Then call Rw("HKCR\.exe\", "piffile", "", ind) End If If (Rr("HKCR\piffile\shell\open\command\") <> """%1"" %*") Then call Rw("HKCR\piffile\shell\open\command\", """%1"" %*", "", ind) End If If (Rr("HKLM\Software\CLASSES\.pif\") <> "piffile") Then call Rw("HKLM\Software\CLASSES\.pif\", "piffile", "", ind) End If If (Rr("HKLM\Software\CLASSES\piffile\shell\open\command\") <> """%1"" %*") Then call Rw("HKLM\Software\CLASSES\piffile\shell\open\command\", """%1"" %*", "", ind) End If ''''''' file .reg If (Rr("HKCR\.reg\") <> "regfile") Then call Rw("HKCR\.reg\", "regfile", "", ind) End If If (Rr("HKCR\regfile\shell\open\command\") <> "regedit.exe ""%1""") Then call Rw("HKCR\regfile\shell\open\command\", "regedit.exe ""%1""", ind) End If If (Rr("HKLM\Software\CLASSES\.reg\") <> "regfile") Then call Rw("HKLM\Software\CLASSES\.reg\", "regfile", "", ind) End If If (Rr("HKLM\Software\CLASSES\regfile\shell\open\command\") <> "regedit.exe ""%1""") Then call Rw("HKLM\Software\CLASSES\regfile\shell\open\command\", "regedit.exe ""%1""", ind) End If ''''''' file .scr If (Rr("HKCR\.scr\") <> "scrfile") Then call Rw("HKCR\.scr\", "scrfile", "", ind) End If If (Rr("HKCR\scrfile\shell\open\command\") <> """%1"" /S") Then call Rw("HKCR\scrfile\shell\open\command\", """%1"" /S", "", ind) End If If (Rr("HKLM\Software\CLASSES\.scr\") <> "scrfile") Then call Rw("HKLM\Software\CLASSES\.scr\", "scrfile", "", ind) End If If (Rr("HKLM\Software\CLASSES\scrfile\shell\open\command\") <> """%1"" /S") Then call Rw("HKLM\Software\CLASSES\scrfile\shell\open\command\", """%1"" /S", "", ind) End If ''''''' conclusioni If (ind = 0) Then MsgBox ("Nessuna modifica apportata.") Else Testo ="Chiavi modificate. È stato generato un report delle azioni eseguite in " & Root() & "report.txt" Testo = Testo & VbCrLf & " Ora dovrebbe funzionare correttamente. In bocca al lupo." MsgBox (Testo) End If End Sub ''''''''''''''''''''''''''''''''''''''''''''''''' ' ' ' zona librerie ' ' ' ''''''''''''''''''''''''''''''''''''''''''''''''' Function Rr(chiave) ' legge un valore nel file di registro Dim R On Error Resume Next Set R = CreateObject("WScript.Shell") Rr = R.RegRead(chiave) End Function Sub Rw(ByVal chiave, ByVal valore, ByVal tipo, ByRef ind) ' scrive nel file di registro, per generare il report dipende dalle sub Rd e report ' se la chiave esiste gia', il suo valore viene sovrascritto ' tipo puo' essere sostituito con una stringa vuota. On Error Resume Next Dim R If (tipo = "") Then tipo = "REG_SZ" End If Set R = CreateObject("WScript.Shell") oldvalue = Rr(chiave) R.RegWrite chiave, valore, tipo ind = ind + 1 If (oldvalue = "") Then call report(chiave, valore, "written", "", ind) Else call report(chiave, oldvalue, "replaced", valore, ind) End If End Sub Sub report (ByVal posizione, ByVal valore, ByVal azione, ByVal sostituto, ByRef ind) ' Genera un report dell'azione eseguita. ' Se l'azione e' la sovrascrittura di una chiave di registro occorre specificare il valore della chiave, altrimenti tale ' parametro viene lasciato vuoto e si indica solo il parametro posizione On Error Resume Next Set fs = CreateObject("Scripting.FileSystemObject") If ind = 1 Then fs.DeleteFile (Root() & "report.txt") End If Set riassunto = fs.OpenTextFile(Root() & "report.txt", 8, True) If (ind = 1) Then riassunto.Write "[Script report]" riassunto.Write VbCrLf & VbCrLf End If If (sostituto <> "") Then add = " by " Else add ="" End If riassunto.Write VbCrLf & "[action: " & ind & "]" If (valore <> "") Then riassunto.Write VbCrLf & posizione & ": value " & valore & " " & azione & add & sostituto Else riassunto.Write VbCrLf & posizione & ": " & azione & add & sostituto End If riassunto.Write VbCrLf riassunto.close End Sub Function Root() ' Cerchiamo su quale unita' si trova il S.O. On Error Resume Next Set fs = CreateObject("Scripting.FileSystemObject") Set fold = fs.GetSpecialFolder(0) Do Until fold.IsRootFolder Set fold = fold.ParentFolder Loop Root = fold End Function