none
Script para remover ponteiro do hosts RRS feed

  • Pergunta

  • Boa noite

    Apliquei este script em 50 maquinas de homologação.

    Dim fsoObject, open_File, target_File
    Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")

    ' ### set the file name to include the variable from the process above
    target_File = "C:\WINDOWS\system32\drivers\etc\Hosts"

     If (fsoObject.FileExists(target_File)) Then
       Set open_File = fsoObject.OpenTextFile(target_File, 8)
     Else
       Set open_File = fsoObject.OpenTextFile(target_File, 2, "True")
     End If

    open_File.WriteLine
    open_File.WriteLine "10.16.0.1 proxy.dominio.local"
    'msgbox "done"
    open_File.Close()

    Mas agora preciso remover o mesmo, alguem sabe como que faço isto via script.

    Grato

    Nielsen

     

    terça-feira, 8 de fevereiro de 2011 20:33

Respostas

  • Utilize um .BAT

     

    @echo off  
      
    SET REGISTRO=10.16.0.1    proxy.dominio.local  
     
    findstr /V /I "%REGISTRO%" %systemroot%\system32\drivers\etc\hosts 
    if NOT %ERRORLEVEL% EQU 0 (  
        findstr /V /I "%REGISTRO%" %systemroot%\system32\drivers\etc\hosts > %systemroot%\system32\drivers\etc\hosts2 
            rename %systemroot%\system32\drivers\etc\hosts hosts.backup 
        rename %systemroot%\system32\drivers\etc\hosts2 hosts 
    )
    

    Referência(s):

    Remover entrada no arquivo hosts

    http://gallery.technet.microsoft.com/scriptcenter/Remover-entrada-no-arquivo-7575d463

     

     


    Fábio de Paula Junior
    terça-feira, 24 de janeiro de 2012 12:04
    Moderador