Pages

Showing posts with label append lines to file using vbscript. Show all posts
Showing posts with label append lines to file using vbscript. Show all posts

Friday 15 June 2012

Create Text file and write lines using VBScript


Following script will create sample.txt file in the location where this script is stored and 10.10..10.93 will be written to sample.txt file




Dim objWshShell, objFSO, sScriptDir
Set objWshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")


sScriptDir=objFSO.GetParentFolderName(WScript.ScriptFullName)
strSecFileName = sScriptDir & "\sample.txt"


Set objSecFile = objFSO.CreateTextFile(strSecFileName, True)
objSecFile.WriteLine("10.10.10.93")


Set objFSO = Nothing
Set objWshShell = Nothing