[RESOLVED] Help Needed for vbscript!
Hi guys,
i'm looking for a vbscript.
i want to update the host file with new one without deleting the contents.
can anyone help me?
there is 3 host file i want to make it one host file.
Kindly help me.
im new im not sure how to do it. still learning.
Re: Help Needed for vbscript!
Here is the vbscript but it doesnt work anymore can anyone help me?
vb Code:
Option Explicit
Dim ObjShell
If WScript.Arguments.length = 0 Then
Set ObjShell = CreateObject("Shell.Application")
ObjShell.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" &_
" RunAsAdministrator", , "runas", 1
Else
'Code here
Dim wshShell, fileSys, oProcEnv, sTemp, sDir, sFile, Source, Target, curPath
'---------------------------------
'Set objShell = CreateObject("Shell.Application")
Set wshShell = WScript.CreateObject("WScript.Shell")
Set fileSys = CreateObject("Scripting.FileSystemObject")
Set oProcEnv = wshShell.Environment("PROCESS")
sTemp = oProcEnv("Temp")
'curPath = fileSys.GetAbsolutePathName(".")
'---------------------------------
'---------------------------------
On Error Resume Next
sFile = "hosts"
'Source = curPath & "\Logs\" & sfile
sDir = wshShell.ExpandEnvironmentStrings("%system32%\drivers\etc\")
Source = sFile
Target = sDir & sFile
'Target = curPath & "\Logs\" & sfile
fileSys.CopyFile (Source), (Target)
'fileSys.DeleteFile(Source)
Set fileSys = nothing
End If