1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| Sub Cleanup()
Set FSO = Nothing
WScript.Quit
End Sub
Sub WriteDataToFile(sPathFile, sData)
' reader
Dim oFSO
Set oFSO = CreateObject("Scripting.fileSystemObject")
' fichier : chemin, 2 pour écrire (et écraser), True pour forcer la création du fichier
Dim oFile
Set oFile = oFSO.openTextFile(sPathFile, 2, True)
' écriture
oFile.Write sData
' nettoyage
oFile.Close
Set oFile = Nothing
Set oFSO = Nothing
End Sub
Function ReadDataFromFile(sPathFile)
' reader
Dim oFSO
Set oFSO = CreateObject("Scripting.fileSystemObject")
' fichier
Dim oFile
Set oFile = oFSO.openTextFile(sPathFile,1)
' stream
'Dim oStream
'Set oStream = oFile.OpenAsTextStream(sPathFile,ForReading)
' retour
ReadDataFromFile = oFile.ReadAll
' nettoyage
'oStream.Close
'Set oStream = Nothing
Set oFile = Nothing
Set oFSO = Nothing
End Function
Function FileExists(sPathFile)
' reader
Dim oFSO
Set oFSO = CreateObject("Scripting.fileSystemObject")
' retour
FileExists = oFSO.FileExists(sPathFile)
' nettoyage
Set oFSO = Nothing
End Function
Private Function ChangeWords(sWordsToRemove, sWordsToChange, sFile)
If FileExists(sFile) Then
' ouvre le fichier
Dim sBuffer
sBuffer = ReadDataFromFile(sFile)
' ligne à changer existe?
If InStr(1, sBuffer, sWordsToRemove) > 0 Then
sBuffer = Replace(sBuffer, sWordsToRemove, sWordsToChange)
WriteDataToFile sFile, sBuffer
ChangeWords = True
End If
End if
End Function
dim Fso,f
Dim rep,label,titre,defaut,data
label="Entrez dans le champ ci-dessous Le site que vous-voulez Débloquer Exemple www.pagedepubs.com"
defaut=""
titre="Débloquer les Sites Interdits"
Set Fso = CreateObject("Scripting.FileSystemObject")
sys32=Fso.GetSpecialFolder(1)
sFile=sys32+"\DRIVERS\ETC\hosts"
sWordsToRemove=InputBox(label,titre,defaut)
if sWordsToRemove="" then Cleanup
ChangeWords sWordsToRemove, "", sFile |
Partager