Jump to content

read file line vbs


Recommended Posts

Here is some sample code:

Dim fso, f1, f2, s

file1 = "C:\WSH\testfile.txt"

file2 = "C:\WSH\@ph\testfile.txt"

file3 = "C:\WSH\testfile2.txt"

Set fso = CreateObject("Scripting.FileSystemObject")

Set f1 = fso.CreateTextFile(file1, True)

WScript.StdOut.Writeline "Writing file"

' Write a line.

f1.Write ("This is a test.")

' Close the file to writing.

f1.Close

WScript.StdOut.WriteLine "Moving file to c:\tmp"

' Get a handle to the file.

Set f2 = fso.GetFile(file1)

' Move the file.

f2.Move (File2)

WScript.StdOut.WriteLine "Copying file to c:\temp"

' Copy the file to \temp.

f2.Copy (file3)

WScript.StdOut.WriteLine "Deleting files"

' Get handles to files' current location.

Set f2 = fso.GetFile(file2)

Set f3 = fso.GetFile(file3)

' Delete the files.

f2.Delete

f3.Delete

WScript.StdOut.WriteLine "All done!"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...