
07-29-2012, 08:28 PM
|
|
Newcomer
|
|
Join Date: Dec 2006
Posts: 3
|
|
VBScript for amend text file
|
Hi Guys,
the below script is the one to amend text file a to text file b.
kindly assist me. this below script is not working. kindly help me.
thanks in advance
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
|
|