NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Last week, I gave an introduction to the Visual Basic Scripting Edition
(VBScript) language and why it is important. This week, we get into some
basic coding, starting with file input and output (i.e. reading and
writing to/from files).

As mentioned in last week's article, VBScript is a language that joins
(or glues) the different components of Microsoft's scripting
technologies together. These components are comprised of automation
objects (COM objects) that expose different parts of an application to
the developer. Automation objects are what make it possible for you to
programmatically access the file system and create, modify, delete,
open, and close files for different purposes.
To open/create a file in VBScript, you must create a handle on the
FileSystemxxx object and then use different methods to manage the file.
For example, let's say that we want to read a list of servers from a
file. To verify that we are reading the proper name from the file, let's
print the name of the file to the screen. Remember from my previous
article on Wscript vs. Cscript, if you use Wscript, then for each line
echoed to the screen, you will receive a message box that you will have
to hit "ok" in order to continue. But if you use Cscript, all of your
output will be displayed to the command prompt window without any
unnecessary prompts. So let's copy the following code to notepad and
save the file to c:scriptsreadFromFile.vbs.
inputFile = "c:scriptsservers.txt",

------------------- Begin Copy -------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("serverList.txt",1)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
Wscript.Echo "Server name: " & strComputer
Loop
--------------------- End Copy -------------------

In addition, create another text file called c:scriptsserverList.txt
with the name of a couple of servers in it, with one server name per
line similar to the following:
serverName1
serverName2
serverName3

Then, let's open a command prompt window and change directories to
c:script. Now, type the following:
cscript readFromFile.vbs

If you did everything correctly, you should receive output that looks
similar to:
------------------- Begin Ouput -------------------

Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

Server name: serverName1
Server name: serverName2
Server name: serverName3

--------------------- End Ouput -------------------

Basically, this code created a handle called "objFSO" (which is the name

I chose) to the object called "Scripting.FileSystemObject". This is the

object that allows you to work with the file system. Next, we created a

handle to a file that resides in the file system using the code:

"Set objTextFile = objFSO.OpenTextFile("serverList.txt",1)"

This created a handle to our file called
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.