Category Archives: write lines using vbscript

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

Advertisements