Free Essay

System Analysis and Design

In: Computers and Technology

Submitted By rgulfo
Words 4473
Pages 18
You can script anything!

Page 1 of 16

Visual Basic Script (VBSCRIPT) – You can script anything!
Automating the Desktop
Visual Basic Scripting is easy to learn and use! It can be used to automate tasks ranging from Windows Desktop Administration, to Microsoft Office Automation, to controlling and extracting information hosted by a 3270 emulation session for the Mainframe. All you need is an ASCII text file that ends in a “.VBS” extension and a little creativity.

A few notes on the language itself:
         Visual Basic Script Edition is a subset of the Visual Basic language. Comments are declared by a single apostrophe, such as: ' This is a VBSCRIPT comment. Variables can be declared using the DIM, PRIVATE, or PUBLIC keywords. Variables have no explicit data type. All data types are “variant” by default. The language is not case-sensitive, so “Acounter”, “ACounter and “aCounter” are considered to be the same variable name regardless of the mix of upper and lower case. Scope is declared using “keyword … END keyword” pairings, such as CLASS…END CLASS, SUB…END SUB, IF … END IF. The unit of program development is the SCRIPT file: an ASCII text file containing executable script statements. Statements are continued by leaving a space at the end of the line followed by an underscore. Strings are concatenated using the ampersand symbol as the concatenation operator.

Your toolkit for script development:
You’ll need a text editor and a Windows client workstation running Windows 98 or above. For the text editor use any ASCII only text editor like Windows Notepad. The product that allows scripts to execute is Windows Script containing Visual Basic Script Edition. The current version at the time of this writing is version 5.6 and it is available for downloading at http://msdn.microsoft.com/scripting . But, before you download anything try the following procedure to see if you have a current version installed on your desktop machine.

Written by John Papproth

You can script anything!

Page 2 of 16

Checking for Windows Script Support:
Start by opening Notepad and entering the following line: MSGBOX WScript.Version Save the file as Version.VBS Note: If you are using Windows Notepad enclose the filename in quotes to avoid having the .TXT extension appended to the filename. Locate the saved Version.VBS file. You should see an icon that looks like Figure 3. You can run the script by opening the saved file. The .VBS extension should be associated with WSCRIPT.EXE by default. Just double-click the icon. If everything goes well, you should see a pop-up message box like Figure 4. Fig 1 – Notepad or any ASCII editor can be used for VBSCRIPT files

Fig 2 – Enclose the File name in quotes to retain the .VBS extension

Fig 3 – The default icon for VBScript files

Written by John Papproth

You can script anything! Fig 4 – Output showing the current Script version

Page 3 of 16

Introduction to Objects:
Object Oriented Programming (OOP) allows you to encapsulate data (fields) and behaviors (properties and methods) using a class. The relationship between a class and an object is similar to the relationship between a blueprint and the home that is built from the blueprint. The class just defines how the object will be built. A full implementation of OOP allows existing classes to be extended by inheritance to create sub-classes. To actually build an object we need to declare a reference of the class and then call the class’s constructor. Each object that is created from a class has it’s own protected set of variables, properties, and methods. In the example above, we referenced an implicit object named Wscript and a property of that object named Version. Note: We did not have to construct an instance (instantiate) of the Wscript object because the script engine had already made this object available to our script. VBSCRIPT has limited (no inheritance) Object Oriented Programming support, which allows you to:  create your own classes using the CLASS statement  provide constructors (initializers) for your class using the SUB CLASS_INITIALIZE event  provide destructors (clean up) for your classes using the SUB CLASS_TERMINATE event  hide or expose data or behaviors using the PRIVATE and PUBLIC access modifiers  provide methods within the class using the FUNCTION and SUB keywords  expose access to hidden variables using the PROPERTY LET and GET statements  create (instantiate) objects that reference your own classes using the NEW keyword In addition to creating objects from your own classes, you can also create references to COM objects using the SET statement and the CreateObject method of the Wscript object.

Creating and using an object in VBScript:
First we need to define a class. We’ll create a class named DemoClass containing a constructor, a destructor, and two public methods: showTime and getTime. The showTime method will not return a value so we’ll use a SUB keyword. The getTime method will return a value with the current time so we’ll use the FUNCTION keyword. We could also have added variables using the PRIVATE access modifier, and PUBLIC properties to retrieve (GET) and update (LET) the variables. Methods, variables, and properties are referred to as “members” of the class.

Written by John Papproth

You can script anything! Fig 5 – A Sample VBSCRIPT Class Definition: DemoClass.vbs class DemoClass public sub class_initialize msgbox "Construction in progress",vbOkOnly,"class_initialize" end sub public sub class_terminate msgbox "Destruction in progress",vbOkOnly,"class_terminate" end sub public sub showTime() msgbox Now(),vbOkOnly,"showTime" end sub public function getTime() getTime = Now() end function end class

Page 4 of 16

Next we need to declare a reference. This is just a placeholder that we can use to later address the object’s members (methods and properties). Fig 6 – Declaring an object reference dim objRef

Finally, let’s call the constructor to create the object and tie it to our reference. If this were a COM object we could also have used the CreateObject method instead of the NEW keyword. Note that Visual Basic Script uses the SET keyword to assign a value to an object reference. The class_initialize is invoked each time the class is instantiated into an object. Fig 7 – Calling the DemoClass Initializer (Constructor) set objRef = new DemoClass

Finally we can use the reference to call our object’s methods and properties using the dot notation. Each public member of the object is available by following the object reference with a period followed by the member name. Fig 8 – Calling an object’s public methods objRef.showTime msgbox objRef.getTime(),vbOkOnly,"Calling getTime"

Ready-made Objects – Wscript, WshShell, WshNetwork, and FileSystemObject:
You have seen in our first example that the Wscript object is implicitly available to the script. The following definitions were taken directory from the Microsoft Developer Network (MSDN) and describe other objects that are built into the scripting engine. The WScript object is the root object of the Windows Script Host object model hierarchy. It never needs to be instantiated before invoking its properties and methods, and it is always available from any script file. The WScript object provides access to information such as:  command-line arguments,  the name of the script file,  the host file name,  and host version information.

Written by John Papproth

You can script anything!

Page 5 of 16

The WScript object allows you to:  create objects,  connect to objects,  disconnect from objects,  sync events,  stop a script's execution programmatically,  output information to the default output device (either a Windows dialog box or the command console). You create a WshShell object whenever you want to run a program locally, manipulate the contents of the registry, create a shortcut, or access a system folder. The WshShell object provides the Environment collection. This collection allows you to handle environmental variables (such as WINDIR, PATH, or PROMPT). You create a WshNetwork object when you want to connect to network shares and network printers, disconnect from network shares and network printers, map or remove network shares, or access information about a user on the network. The FileSystemObject is used to provide access to a computer’s file system.

Limited Input and Output to the Window’s Desktop – Inputbox, Msgbox, and wshShell.PopUp:
For returning input text from the user, VBSCRIPT provides an INPUTBOX function that accepts three string values as input parameters: a prompt, a title for the window caption, and a default value. If the OK button is clicked, the value entered by the user is returned as a string. If the CANCEL button is clicked a zero length string is returned. Fig 9 – InputBox Dialog

dim response response=inputbox(msg,title,defaultValue)

Written by John Papproth

You can script anything!

Page 6 of 16

The MSGBOX also accepts three input parameters: a message to be displayed, a button and icon value, and a title for the caption of the dialog window. It displays a dialog box that waits for the user to click a button before returning to the script. Unlike INPUTBOX the response that is returned is not text, but the numeric value corresponding to the button that was clicked. These numeric values are represented by mnemonic constants. Fig 10 – MsgBox Dialog

dim response dim msg dim title msg = "Continue?" title = "Confirm" response=msgbox(msg,vbYesNo+vbInformation,title) If response = vbYes then Else ' No was clicked! End if

wshShell.PopUp – MSGBOX without the wait!
The wshShell.PopUp method performs in a manner similar to the MSGBOX function. However, the POPUP method does not have to wait for a response by the user. A number of seconds to wait is supplied to the POPUP function as an additional input parameter. If “SecondsToWait” equals zero (the default), the pop-up message box remains visible until closed by the user. In this case the effect is the same as MSGBOX. However, if “SecondsToWait” is greater than zero, the pop-up message box closes after “SecondsToWait” seconds have elapsed with no interaction from the user. Fig 11 – Using the Popup Method of the Shell Object

dim btnReturn dim waitSeconds dim buttons dim icon dim wshShell Set wshShell = CreateObject("Wscript.Shell") buttons = vbOkOnly icon = vbInformation waitSeconds = 10 btnReturn = wshShell.Popup(msg, waitSeconds, title, buttons + icon)

Written by John Papproth

You can script anything!

Page 7 of 16

MSGBOX (and wshShell.PopUp) Constants
The Msgbox statement and the PopUp method can share the same VBSCRIPT MSGBOX constants that are used to define the values for the buttons and icon. The following tables were taken directly from the VBSCRIPT Reference page on MSDN. The following constants are used with the MsgBox function to identify what buttons and icons appear on a message box and which button is the default. In addition, the modality of the MsgBox can be specified. Since these constants are built into VBSCRIPT, you don't have to define them before using them. Use them anywhere in your code to represent the values shown for each. Fig 12 – VBScript Constants to define MsgBox Button Configurations Constant Value Description vbOKOnly 0 Display OK button only. vbOKCancel 1 Display OK and Cancel buttons. vbAbortRetryIgnore 2 Display Abort, Retry, and Ignore buttons. vbYesNoCancel 3 Display Yes, No, and Cancel buttons. vbYesNo 4 Display Yes and No buttons. vbRetryCancel 5 Display Retry and Cancel buttons. vbCritical 16 Display Critical Message icon. vbQuestion 32 Display Warning Query icon. vbExclamation 48 Display Warning Message icon. vbInformation 64 Display Information Message icon. vbDefaultButton1 0 First button is the default. vbDefaultButton2 256 Second button is the default. vbDefaultButton3 512 Third button is the default. vbDefaultButton4 768 Fourth button is the default. vbApplicationModal 0 Application modal. The user must respond to the message box before continuing work in the current application. vbSystemModal 4096 System modal. On Win16 systems, all applications are suspended until the user responds to the message box. On Win32 systems, this constant provides an application modal message box that always remains on top of any other programs you may have running.

The following constants are used with the MsgBox function to identify which button a user has selected. Fig 13 – MsgBox Constant Value vbOK 1 vbCancel 2 vbAbort 3 vbRetry 4 vbIgnore 5 vbYes 6 vbNo 7 Constants returned by the MsgBox Dialog Description OK button was clicked. Cancel button was clicked. Abort button was clicked. Retry button was clicked. Ignore button was clicked. Yes button was clicked. No button was clicked.

Written by John Papproth

You can script anything!

Page 8 of 16

Pieces of a working script:
The following example, DESKTOP.VBS, was developed to demonstrate the basic desktop input and output facilities that are available to the script developer. The script itself also uses encapsulation to demonstrate the Object Oriented capabilities in VBSCRIPT. It is composed of the script mainline and two in-line class definitions. All definitions are contained in a single text file named: Desktop.VBS The function of this script is a bit contrived (but serves as a good demonstration): to prompt for a directory name, change the current directory, and then list the files within that directory. The script mainline declares two variables to hold object references of each class type. Public methods and properties of the objects are called to change and then display the contents of a folder. Fig 14 – Referencing the UserInfo and DesktopIO class
Option Explicit ' ' Desktop.VBS ' written by John Papproth ' Demonstrates limited Desktop Input/Output and OOP facilities of VBSCRIPT ' Dim objUserInfo Dim objDesktopIO Set objUserInfo = new UserInfo Set objDesktopIO = new DesktopIO objUserInfo.currentDirectory = _ objDesktopIO.prompt("Enter a directory: ", _ "Change Directory", _ objUserInfo.currentDirectory) Call objUserInfo.showDir() '-------------------------------------------------------------

The DesktopIO class simply provides an encapsulation around the MSGBOX and INPUTBOX functions. While this was definitely not necessary it provides a simple example of the CLASS statement and the use of both a SUB and FUNCTION as methods of the class. In VBSCRIPT, a method created using the SUB keyword cannot return a value, while a method created as a FUNCTION returns a value by setting the name of the FUNCTION equal to the return value before exiting. Fig 15 – DesktopIO Class encapsulates MsgBox and InputBox
' ' Class DesktopIO ' Class DesktopIO public sub alert(msg,title) msgbox msg,vbOkOnly+vbInformation,title end sub public function prompt(msg,title,defaultValue) prompt=inputbox(msg,title,defaultValue) end function End Class

The UserInfo class is an example of encapsulating both data and behavior together. All data items are hidden from direct access outside of the class by using the PRIVATE access modifier. The SUBs CLASS_INITIALIZE and CLASS_TERMINATE are used to instantiate and then release the object references that are used by the class. This class also provides examples of:  a READ/WRITE property, currentDirectory.  a public method, showDir, which is used to display the directory contents.  a private method, show, which acts as a wrapper around the wshShell.PopUp method.

Written by John Papproth

You can script anything!

Page 9 of 16

Fig 16 – UserInfo Class exposing private fields with public properties
' ' Class UserInfo ' Class UserInfo private private private private private private private private strDomainName strComputerName strUserName strCurrentDirectory wshShell wshNetwork fso io

public sub class_initialize set wshShell = CreateObject("Wscript.Shell") set wshNetwork = CreateObject("Wscript.Network") set fso = CreateObject("Scripting.FileSystemObject") set io = new DesktopIO strDomainName = WshNetwork.UserDomain strComputerName = WshNetwork.ComputerName strUserName = WshNetwork.UserName strCurrentDirectory = WshShell.CurrentDirectory call show("Hello " & strUserName & vbCrLf & _ "Logged in at: " & _ "\\" & strDomainName & "\" & strComputerName & vbCrLf & _ "Current folder: " & _ strCurrentDirectory & _ "","UserInfo") end sub public sub class_terminate call show("Goodbye " & strUserName,"UserInfo") set wshShell = Nothing set wshNetwork = Nothing set fso = Nothing set io = Nothing end sub public property GET currentDirectory() currentDirectory = strCurrentDirectory end property public property LET currentDirectory(value) WshShell.CurrentDirectory = value strCurrentDirectory = WshShell.CurrentDirectory call show("Current folder: " & _ strCurrentDirectory & _ "","UserInfo") end property public sub showDir() dim folder dim file dim fileList set folder = fso.GetFolder(strCurrentDirectory) fileList = "" for each file in folder.Files fileList = fileList & file.name & vbCrLf next call io.alert(fileList,"Dir for " & strCurrentDirectory) end sub private function show(msg,title) dim btnReturn dim waitSeconds dim buttons dim icon buttons = vbOkOnly icon = vbInformation waitSeconds = 10 btnReturn = wshShell.Popup(msg, waitSeconds, title, buttons + icon) show = btnReturn end function End Class

Written by John Papproth

You can script anything!

Page 10 of 16

Creating and Reading ASCII files – FileSystemObject and the TextStream Object:
The FileSystemObject is used to provide access to a computer’s file system. Two of its methods will allow us to create a TextStream object. The TextStream object is used to provide sequential access to a file. You can create a new file or overwrite an existing file by using the FileSystemObject.CreateTextFile method. You can open both a new and existing file by using the FileSystemObject.OpenTextFile method. Fig 17 – TextStream Object (created by FileSystemObject methods) Methods: Properties:

Close Method (FileSystemObject object) Read Method ReadAll Method ReadLine Method Skip Method SkipLine Method Write Method WriteBlankLines Method WriteLine Method

AtEndOfLine Property AtEndOfStream Property Column Property Line Property

A Class to read and write text files:
The TextIO class that is defined below encapsulates the relationship between the FileSystemObject and the TextStream object and provides several methods for interacting with text files. The following code demonstrates the use of the TextIO class. We begin by creating a TextIO object reference, and then demonstrate how to create, append, and read from a text file. Fig 18 – IOTest Mainline referencing the TextIO Class
Option Explicit ' ' IOTest.vbs ' written by John Papproth ' Demonstrates the text Input/Output facilities of VBScript ' dim i dim io set io = new TextIO ' ' Create ' msgbox "Creating a new file!",vbOkOnly,"IO Test" call io.openOutput("IOTest.txt") for i = 1 to 5 call io.putLine("Line " & i & "..." & Now) next call io.close ' ' Append ' msgbox "Appending to an existing file!",vbOkOnly,"IO Test" call io.openAppend("IOTest.txt") for i = 1 to 5 call io.putLine("Appended Line " & i & "..." & Now) next call io.close ' ' Read ' msgbox "Reading the file!",vbOkOnly,"IO Test" call io.openInput("IOTest.txt") do msgbox io.getLine() loop until io.EOF call io.close

Written by John Papproth

You can script anything!

Page 11 of 16

Fig 19 – TextIO.vbs encapsulates TextStream methods in an external class
' ' Class TextIO ' Class TextIO Private ForReading private ForWriting private ForAppending private fso private ts private s ' constants for IO ' constants for IO ' constants for IO ' File System Object ' Text Stream ' Stream line

private sub Class_Initialize ForReading = 1 ForWriting = 2 ForAppending = 8 Set fso = CreateObject("Scripting.FileSystemObject") End sub private sub Class_Terminate end sub public function openInput(s) Set ts = fso.OpenTextFile(s, ForReading, True) end function public function openOutput(s) Set ts = fso.OpenTextFile(s, ForWriting, True) end function public function openAppend(s) Set ts = fso.OpenTextFile(s, ForAppending, True) end function public function getLine() Dim s s = ts.readLine() getLine = s end function public function putLine(s) ts.WriteLIne(s) end function public function close() ts.Close end function public Property GET EOF() EOF = ts.AtendOfStream End property end Class

Advanced Input/Output using HTML and ActiveX:
You can combine the class definitions, script, and HTML to take full advantage of the presentation capabilities that are available in the browser. In the example below we added a script tag to bring in our TextIO class definition as a separate file. We then added a method to read the file using the filename that was selected in the HTML page. Finally we tied the readFile method to the onClick event of the READ button on the HTML page. The result is an ActiveX browser that reads external text files into a table on the HTML page.

Written by John Papproth

You can script anything! Fig 20 – ReadFile.html using an HTML page for presentation

Page 12 of 16

Read File option explicit sub readFile() dim io dim s dim f f = InputFile.value set io = new TextIO io.openInput(f) s = "" do s = s & io.getLine() & vbCrlf loop until io.EOF io.close contentName.innerText = f content.innerText = s end sub Click BROWSE to select a file: Click READ/SHOW to view the selected file:

Automating Desktop Administration:
MSDN states that Windows Management Instrumentation (WMI) provides access to information about objects in a managed environment. Through WMI and the WMI application programming interface (API), applications can query for and make changes to static information in the Common Information Model (CIM) repository and dynamic information maintained by the various types of providers. Combining script and WMI gives you easy access to the objects within the Windows Operating System. For more information on WMI check out MSDN at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_wmi.asp As an example, here is a script that reboots the workstation after a 10-second delay.

Written by John Papproth

You can script anything! Fig 21 – SystemReboot.vbs Using the WMI API
Option Explicit '-----------------' ' SystemReboot.vbs ' Written by John Papproth ' Reboots after 10 seconds ' '-----------------Dim obj Set obj = new SysCmd Call obj.Reboot

Page 13 of 16

' ' SysCmd Class ' Methods: Logoff,Shutdown,Reboot,Poweroff,Confirm,Notify,Shell ' Class SysCmd '--------------------------------------------------------------' ' private: ' wshNetwork ' wshShell ' ' Private Sub Class_Initialize ' Private Sub Class_Terminate ' Private Sub Win32Shutdown(opt) ' Private Function popup(Prompt,Title,SecondsToWait,Buttons,Icons) ' ' public: ' Public Sub Logoff() ' Public Sub Shutdown() ' Public Sub Reboot() ' Public Sub Poweroff() ' Public Function Confirm(Prompt,Title,SecondsToWait) ' Public Sub Notify(Prompt,Title,SecondsToWait) ' Public Sub Shell(cmdString) ' '--------------------------------------------------------------private wshNetwork private wshShell Private Sub Class_Initialize set wshNetwork = CreateObject("Wscript.Network") Set wshShell = CreateObject("Wscript.Shell") End Sub Private Sub Class_Terminate ' Nothing to do here! End Sub Private Sub Win32Shutdown(opt) if Confirm("Continue?","Shutting down...",10) then dim objWMIService dim strComputer dim colItems dim objOperatingSystem strComputer = "." Set objWMIService = GetObject("winmgmts:" & _ "{impersonationLevel=impersonate,(Shutdown)}!\\" & _ strComputer & _ "\root\cimv2") set colItems = objWMIService.ExecQuery( _ "Select * from Win32_OperatingSystem" _ ) for each objOperatingSystem in colItems objOperatingSystem.Win32Shutdown(opt) next end if End Sub Public Sub Logoff() const LOGOFF = 0 Win32Shutdown(LOGOFF) End Sub Public Sub Shutdown() const SHUTDOWN = 1 Win32Shutdown(SHUTDOWN)

Written by John Papproth

You can script anything!

Page 14 of 16

End Sub Public Sub Reboot() const REBOOT = 2 Win32Shutdown(REBOOT) End Sub Public Sub Poweroff() const POWEROFF = 8 Win32Shutdown(POWEROFF) End Sub Private Function popup(Prompt,Title,SecondsToWait,Buttons,Icons) dim btnReturn btnReturn = wshShell.Popup( _ Prompt, _ SecondsToWait, _ Title, _ Buttons + Icons) popup = btnReturn End Function Public Function Confirm(Prompt,Title,SecondsToWait) if popup(Prompt,Title, SecondsToWait, vbYesNo, vbQuestion) = vbNo then Confirm=false else Confirm=true end if End Function Public Sub Notify(Prompt,Title,SecondsToWait) Call popup(Prompt, Title, SecondsToWait, vbOkOnly, vbInformation) End Sub Public Sub Shell(cmdString) wshShell.run(cmdString) End Sub End Class

Automating a Microsoft Office Application:
Microsoft Office applications can be automated using Visual Basic for Applications (VBA) which runs within the Office product as a macro extension. However, you can also control Microsoft Office by creating a reference to the Application object. Here is a short example to demonstrate how easy it is to start an office application and then interact it with using VBScript. Fig 22 – ExcelTest.vbs Scripting Microsoft Office
Option Explicit ' ' ExcelTest.vbs ' written by John Papproth ' dim objExcel dim row dim col Set objExcel = CreateObject("Excel.Application") objExcel.Workbooks.Add row = 1 col = 1 objExcel.ActiveSheet.Cells(row,col) = Now objExcel.Selection.NumberFormat = "mmmm d, yyyy" objExcel.Selection.Font.Name = "Arial" objExcel.Selection.Font.FontStyle = "Regular" objExcel.Selection.Font.Size = 14 objExcel.ActiveWorkbook.SaveAs "ExcelTest.xls" objExcel.Visible = True

Written by John Papproth

You can script anything!

Page 15 of 16

Each office application has a macro recording facility that creates VBA as you are manually performing the steps (such as changing fonts, saving files, etc). See the Tools/Macro menu under your office application to try this. After recording a macro in VBA you can then view the recorded VBA statements and change them into a stand alone VBSCRIPT by qualifying the object references with your script application object name (objExcel in my example above).

Automating Attachmate Mainframe HLLAPI from VBSCRIPT:
Attachmate Extra has a facility for creating macros by recording keystrokes and producing VBA-like output. In a manner similar to automating Microsoft Office, we can also create stand-alone scripts for our host session. Here is an example of a script that connects to an existing Host session, sends a simple command, and then captures and displays the output. Fig 23 – Scripting the Mainframe with Attachmate Extra!
Option Explicit ' ' HostTester.vbs ' written by: John Papproth ' ' Purpose: Demonstrates a connection to an Attachmate Extra Session ' ' Call Main Sub Main() Dim Dim Dim Dim Dim Dim Dim Dim Dim Dim System ' Session ' Screen ' milliseconds Rows ' Cols ' Row Buffer Line Lines ' ' ' ' Attachmate System Current Host Session Current Screen ' milliseconds to wait Rows in Current Screen Cols in one Row Row Counter Buffer to hold Screen Image One Line All Lines belimited by vbCrLf ' 1000=1 second

milliseconds = 500

Set System = CreateObject("Extra.System") if System is Nothing Then Msgbox "Could not create the System Object", _ vbOkOnly+vbCritical,"Get Screen" Exit Sub End If Set Session = System.ActiveSession if Session is Nothing Then Msgbox "Could not create the Session Object", _ vbOkOnly+vbCritical,"Get Screen" Exit Sub End If Set Screen = Session.Screen Call Screen.SendKeys("TIME") ' Can be any HOST command Call Screen.WaitHostQuiet(milliseconds) Rows = Screen.Rows() Cols = Screen.Cols() Buffer = Screen.GetString(1,1,Rows*Cols) Lines = "" For Row = 1 to Rows Line = Mid(Buffer, ((Row-1)*Cols) + 1, Cols) Lines = Lines & Line & vbCrlf Next Msgbox Lines,vbOkOnly+vbInformation,"Screen" End Sub

Written by John Papproth

You can script anything!

Page 16 of 16

Where to go for more information:
Microsoft provides many code examples on its scripting development center: http://msdn.microsoft.com/scripting Although this article has focused on VBSCRIPT, the Windows Script product also supports Jscript (Microsoft’s version of Javascript). If you are so inclined, you may also want to experiment with other scripting languages such as ActiveState’s Perl (http://www.activestate.com/perl ).

Did I mention?…VB.NET, ADO, WINHTTP, and MSSOAP:
The real power of VBScript (or any script interface) is the ability to create and attach to COM objects. Did I mention that you could create your own COM objects using Visual Basic 6.0 or COM Wrappers for VB.NET Components? But before you create your own objects, do a little research on MSDN. There are existing COM objects for database (ADODB), web document (WINHTTP), and web service (MSSOAP) processing!

About the author:
NasPa member John Papproth is a both a MCSD.NET (Microsoft Certified Solution Developer) and SCJP (Sun Certified Java Programmer). He is a consultant for Bass & Associates Inc. a Business Solutions Provider in Omaha NE. John has taught courses in both the Microsoft .NET language suite and the Sun Microsystems Java Language. He can be reached at john@papproth.com.

Resources: http://msdn.microsoft.com/scripting http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_wmi.asp http://www.activestate.com/perl

Written by John Papproth…...

Similar Documents

Premium Essay

Essentials of Systems Analysis and Design

... This page intentionally left blank Download at www.Pin5i.Com Essentials of Systems Analysis and Design Download at www.Pin5i.Com Editorial Director: Sally Yagan Editor in Chief: Eric Svendsen Executive Editor: Bob Horan Editorial Assistant: Ashlee Bradbury Director of Marketing: Patrice Lumumba Jones Executive Marketing Manager: Anne Fahlgren Senior Managing Editor: Judy Leale Production Project Manager: Kelly Warsak Senior Operations Supervisor: Arnold Vila Operations Specialist: Cathleen Petersen Creative Director: Blair Brown Senior Art Director/Design Supervisor: Janet Slowik Text Designer: Michael Fruhbeis Creative Director/Cover: Jayne Conte Cover Designer: Suzanne Duda Cover Art: Fotolia/3d mosaic/©Redshinestudio Manager, Rights and Permissions: Hessa Albader Media Project Manager: Lisa Rinaldi Media Editor: Denise Vaughn Full-Service Project Management: Tiffany Timmerman/S4Carlisle Publishing Services Composition: S4Carlisle Publishing Services Printer/Binder: Courier/Kendallville Cover Printer: Lehigh-Phoenix Color/Hagerstown Text Font: ITCCentury Book Credits and acknowledgments borrowed from other sources and reproduced, with permission, in this textbook appear on appropriate page within text. Microsoft® and Windows® are registered trademarks of the Microsoft Corporation in the U.S.A. and other countries. Screen shots and icons reprinted with permission from the Microsoft Corporation. This book is not sponsored or endorsed by or affiliated with the......

Words: 179288 - Pages: 718

Premium Essay

System Analysis, Design and Implementation

...Stephanie Cook ITM 5400 FALL I 2013 System Analysis, Design and Implementation Professor Al Marcella Cook_7A 1. Should Top Sail implement a Web-based system? Why or why not? I do feel that Top Sail should implement a Web-based system in order to be effective in the time-sharing and rental broker business. Most every major company as well as brick and mortar companies are breaking through with Web based systems. Customers look to make everything convenient for them. Purchases and rentals of most all products via the Internet is how most customer are buying now days therefore this is a must for Top Sail. They need a system that will display relevant information pertaining to rentals, availability and prices and exactly what potential renters prefer and/or looking for. 2. What software acquisition options are available to Top Sail? The software acquisition options that are available to Top Sail must begin with the acquisition process. Step 1 is to evaluate the Information System requirements and prepare a request for proposal or a request for quotation, Step 2 is to identify potential vendors or outsourcing options, Step 3 evaluate the alternatives, Step 4 is to perform cost-benefit analysis, Step 5 prepare a recommendation and Step 6 implement the solution. They can develop a system, buy a software package or customize a software package. In Top Sail’s case customizing a software package would probably be the best route to take and in......

Words: 466 - Pages: 2

Premium Essay

Systems Analysis and Design

...Running head: SYSTEMS ANALYSIS AND DESIGN Torey Golden Unit 6 Assignment 6 IT510 Kaplan University Table of Contents Part 1 3 Part 2 4 Part 3 7 References 9 Part 1 The team is now at the end of this information systems project for the company’s advertising personnel. We have been recently informed that they will be an employment reduction that will affect the systems analysis team and our budget which in turn has affected moral based on Ontha Weyout’s response during the meeting. We have identified that while we do have documentation, there is no consistency in it. A standardized method is in need to consolidate it and make the information understandable for users and stakeholders to use. One of the programmers suggested using psuedocode to standardize the documentation. However the advertising personnel are not familiar with that method. Had Al who is one of our newest programmers explained how Rouse (2005) stated that psuedocode “is a detailed yet readable description of what a computer program or algorithm must do” he might have received a different response from Mark in advertising. In addition, Al’s peer Flo and advertising executive David do not embrace the idea of using psuedocode. They have been using the systems development process with the use of CASE tools. The CASE tool can output graphical diagrams to give programmers a picture of what they are creating and non-technical users a map of sorts. It also provides......

Words: 1880 - Pages: 8

Premium Essay

Systems Analysis, Design, and Integration

...Table of Contents System or Application Overview 3 Brief Description 3 Intended Users 3 Project Initiator 3 Requirements Specification 4 Overall Goals 4 Requirements Gathering 4 Functional Requirements 4 Describe nonfunctional requirements 4 Functions and constraints used to frame the scope 4 Application Design 5 High Level Use Case Diagram 5 Functional Decomposition Diagram 6 Class Diagram 7 Sequence Diagram 8 Story Board 8 Test and Quality Assurance Plan 9 Unit Tests 9 System Tests 9 Acceptance Tests 10 Bug Tracking 10 Development Strategy 11 Insourcing 11 Pros 11 Cons 11 Outsourcing 11 Pros 12 Cons 12 Combination 12 Pros 12 Cons 13 Financial Analysis 13 Investment 13 Savings 13 Timing 13 Strategic Fit 13 Economic Impact 13 Operational Model 13 Cultural Fit 13 Risk Management 14 Recommendation 14 Integration and Deployment Plan 15 Work Breakdown Structure 15 References 17 System or Application Overview Brief Description This document will be used to track the Requirements, Design and Implementation of a Time Card System. This system will be used to track the time 20 different employees spend working on different projects. It will also allow managers to run reports allowing them to track time by either employee or project. Intended Users This system will be used by both employees and managers. Employees will need to clock in to the current project, clock out, and change projects...

Words: 3357 - Pages: 14

Premium Essay

System Analysis and Design

... The primary role of systems analysts and designers is, of course, to produce a computer system solution to a problem that meets the customer’s requirements. This task can easily be so absorbing in itself that there is seemingly no time left over for thinking about the non-technical issues surrounding the introduction of a new IT system, much less for setting up a people project to address them. So even if the people project is not driven by analysts, designers, or even IT managers, it needs their active support. Many of the tasks carried out by analysts in the early stages of an IT development project have outputs that the people project will need to draw on. For example, the process of creating data models and data flow diagrams may raise questions of data ownership, which need to be fed to the people project to resolve, perhaps through a redefinition of rolesand responsibilities or the introduction of a new procedure. Likewise, if systems analysts have done a detailed assessment of costs and benefits, this will give the people project some idea of the messages they can use to sell the new IT system to users and managers. Analysts can also draw on the people project for valuable help in areas such as human–computer interface design, discussed in Chapter 15. The look and feel of the HCI can be one of the most significant factors in determining a user’s response to a system. The people project can help create the conditions in which HCI design can be done......

Words: 11373 - Pages: 46

Premium Essay

Accounting System Analysis & Design

...ACCOUNTING SYSTEM ANALYSIS & DESIGN ANSWER FOR TUTORIAL 3 There are several methods that systems analysts use to determine requirements for a proposed system. The requirements gathering techniques can be categorized into traditional, modern, or radical. The traditional requirements gathering techniques are interviews, questionnaires, , and documents analysis. The modern requirements determination techniques include Joint Application Design (JAD), group support systems, prototyping, and CASE tools. Business Process Reengineering (BPR) is a radical method for determining system requirements. Each of these approaches has advantages and disadvantages to system implementation and operation. 1. Briefly describe systems analysis and the major activities that occur during this phase of the systems development life cycle. (4 Marks) Answer: Systems analysis involves determining how the current information system functions and assess what users would like to see in a new system. Requirements determination, requirements structuring, and alternative generation and selection are the three primary systems analysis activities. 2. Describe THREE (3) traditional techniques for collecting information during analysis. When might one be better than another? (6 Marks) Answer: Traditional techniques for collecting requirements include interviewing individuals, interviewing groups, observing users, and document and procedure......

Words: 689 - Pages: 3

Premium Essay

System Analysis and Design

...CBAD2103 SYSTEM ANALYSIS AND DESIGN Name : Afiq Aiman Bin Halilludin Matric number : 860819355417001 NRIC : 860819-35-5417 Telephone number : 016-4612503 E-mail address : mynameisafiq@gmail.com E-Tutor’s name: Noor Anida Zaria Binti Mohd Noor Learning Centre: Seameo Recsam Learning Centre September 2014 Semester TABLE OF CONTENTS 1.0 INTRODUCTION…………………………………………………….……….………....3 1.1 CONTEXT DIAGRAM…….…………………………………………….…………..…. 3 1.2 CONTEXT DIAGRAM FOR HEALTH CLUB MEMBERSHIP……………………4 2.0 DATA FLOW DIAGRAM (DFD)…………………….……………………..……….…5 2.1 DATA FLOW DIAGRAM FOR HEALTH CLUB MEMBERSHIP SYSTEM…......6 3.0 NON-FUNCTIONAL REQUIREMENTS……………………………………………..7 4.0 TANGIBLE AND INTANGIBLE BENEFIT…………………………………………..9 5.0 REFERENCE…………………………………………………...………………………10 1.0 INTRODUCTION 1.1 Context diagram In this assignment, I am required to develop a health club system in order to manage membership transaction. I will draw a context diagram and data flow diagram (level 0). Besides that, I will also describe the non-functional requirements that reflect the system characteristics as well as tangible and intangible benefit of the system. A Context Diagram in the field of software engineering and systems engineering is a diagram that defines the boundary between the system, part of a system and its surroundings, which shows the entities that interact with it. This diagram is a high level view of a system. System context......

Words: 1673 - Pages: 7

Premium Essay

System Analysis and Design

...Echols 1/10/2014 Unit 2 Research Assignment System Analysis and Design refers to the process of examining a business situation with intent to improving through bettering procedures and methods. System analysis and design relates to shaping organizations, improving performance and achieving objectives for profitability and growth. Systems development can generally be thought of as two components: Systems analysis and Systems design. System design is the process of basically planning a business system or replace/complement an existing system. Planning on what can be done, understanding of the old system is use to determine on how computers can be used to make its operation more effective. System analysis, the process of gathering and interpreting facts, diagnosing problems, and using the information to recommend improvement to a system or systems. Topic headings that I discovered when requirement analysis was searched was giving definition to a business and a computer science. In business and computer science describes the same definition to the process of user expectations for a new or modified product that’s relevant and detailed. According to the website http://searchsoftwarequality.techtarget.com/, the requirement analysis gives same definition. Out of all the definitions that Ive read, this website gives me the best definition. It also mentions further that it involves frequent communication with system users to determine specific feature expectations,......

Words: 297 - Pages: 2

Premium Essay

System Analysis and Design

...Written Assignment: 1. Chapter 1 – Introduction to System Analysis and Design Answer questions 1, 2, 3, found on page 34 of the reading, and answer minicase 1 Learning Outcomes: LO1, LO2, LO3) a. What are the six general skills all project team members should have? Six general skills all project team members should have are technical, business, analytical, interpersonal, management, and ethical. b. What are the major roles on a project team? There are five major roles on a project team that have to work together to succeed. The five roles that are needed is a business analyst, systems analyst, infrastructure analyst, change management analyst, and a project manager. c. Compare and contrast the role of a systems analyst, business analyst, and infrastructure analyst. The roles of systems analyst is to identify how technology can improve business processes, design new business processes, design the information system, and ensuring that the system conforms to information systems standards. The roles of a business analyst is to analyze the key business aspects of the system, identify how the system will provide business value, and design the new business process and policy. The roles of an infrastructure analyst is to ensure that the system conforms to infrastructure standards and identify infrastructure changes needed to support the system. d. Minicase 1 i. LO1 Follow the original plan given to you by the IS experts. ...

Words: 771 - Pages: 4

Premium Essay

Systems Analysis & Design

...| |Module Title: |Systems Analysis & Design | |Programme: |Computer Science/Computer Science with Business Informatics | |Level: |Level 5 | |Awarding Body: |Plymouth University | |Module Leader: |Nikita Mazurov | |Format: |Systems Analysis and Design Portfolio Document | |Presentation: |No | |Any special requirements: |No | |Word Limit: |Between 1500-2000 words. | |Deadline date for submission: |Week 10, specifically: Wednesday, 12th August 2015, 12:00 pm (noon). | |Learning outcomes to be examined |Demonstrate an understanding of how business needs determine system design. | |in this......

Words: 2100 - Pages: 9

Premium Essay

Modern System Analysis and Design

...Modern Systems Analysis and Design, 6e (Hoffer, et al.) Chapter 2 The Origins of Software 1) Hardware manufacturers are one source of software. Answer: TRUE Diff: 2 Page Ref: 33 2) The first administrative information system was General Electric's payroll system. Answer: TRUE Diff: 2 Page Ref: 30 3) Internal corporate information systems departments now spend a smaller portion of their time and effort on developing systems from scratch. Answer: TRUE Diff: 1 Page Ref: 30 4) Third-party sourcing is the practice of turning over responsibility of some to all of an organization's information systems applications and operations to an outside firm. Answer: FALSE Diff: 2 Page Ref: 30 5) Outsourcing is an alternative analysts need to be aware of. Answer: TRUE Diff: 1 Page Ref: 32 6) An organization may move to outsourcing for political reasons. Answer: TRUE Diff: 1 Page Ref: 31 7) Reducing time to market is one reason for outsourcing. Answer: TRUE Diff: 2 Page Ref: 31 8) Hiring a company to run your applications on your own computers is an example of outsourcing. Answer: TRUE Diff: 2 Page Ref: 31 9) A company may consider outsourcing if it feels that its core mission does not involve managing an information systems unit and that it might achieve more effective computing by turning over all of its operations to a more experienced, computer-oriented company. Answer: TRUE Diff: 2 Page Ref: 31 10) Based on 2007 total revenues, the...

Words: 5644 - Pages: 23

Premium Essay

System Design & Management Analysis

...SYSTEM DESIGN & MANAGEMENT ANALYSIS System Design & Management Analysis Veronica Brown-Corbin University of Phoenix Contemporary Systems Management MGT/736 Brian E. Polding, Ph.D March 12, 2007 System Design & Management Analysis Management must recognize the system design and management of an organization are subject to internal and external influences. The internal influences include the management team and employee; and the external influences can include competitors and customers. There are contextual/cultural factors and stakeholders that have an influence on the management system that is designed and implemented. The contextual/cultural factors include key characteristics of the organization, internal and external relations, competitive landscape, strategic opportunities and challenges, and performance improvement. This is an opportunity for executive management to become acquainted with how these influences shape the organization’s context and maximize value for stakeholders. “Leadership’s job was to get the strategy right, design the correct structure, and then tie the strategy to structure through defined systems to deliver high-quality performance” (Nowicki & Summers, 2007, p.118). This is not an easy process and takes time and input from several sources. The leadership in the organization has to guide the organization so that the goals and objectives are met. The performance of the organization will benefit from a well carried out strategic......

Words: 1974 - Pages: 8

Premium Essay

System Analysis and Design

...A Database Monitoring of Transactions for Billing System of Luna Mystique Worldwide Transport Air Express Incorporated -------------------- A Project Presented to the Faculty of the College of Engineering and Technology Universidad De Manila A.J. Villegas Street Ermita, Manila -------------------- In Partial Fulfillment of the requirements for the Degree Bachelor of Science in Financial Accounting SYSTEM ANALYSIS AND DESIGN -------------------- By Gonzales, Charline S. Mendoza, Mary Joy B. September 2015 Professor Elmerito Pineda Abstract The study aims to detect the possible reasons for the problems encountered in the billing system of the company and to provide a solution for such problems. The study focus on the billing system which is one of the important part of the business because it involves the billing of clients for the services rendered by the company. The existing system in the air freight department was selected to provide and illustrate the processing of transactions before it flows into the billing system. To accomplish the goal of the study, the objectives are set and some techniques and methods are used to come up with accurate and reliable information needed in the study. Thorough analysis are made. The conclusions and recommendations are made. And the result of the study discovered the main reason for those problems encountered in the billing system of the department, or in the company as a......

Words: 731 - Pages: 3

Premium Essay

System Analysis and Design

...– Introduction to Systems Analysis and Design MULTIPLE CHOICE 1. ____ refers to the combination of hardware, software, and services that people use to manage, communicate, and share information. a. Information systems b. Information technology c. Computer systems d. Computer technology PTS: 1 REF: 4 2. ____ software controls the flow of data, provides data security, and manages network operations. a. Enterprise c. Application b. System d. Legacy PTS: 1 REF: 7 3. Examples of company-wide applications, called ____, include order processing systems, payroll systems, and company communications networks. a. enterprise applications c. operating applications b. network operating systems (NOS) d. legacy systems PTS: 1 REF: 8 4. Over 40 years ago, a concept called Moore’s Law accurately predicted that computer processing power would double about every ____. a. 2 months c. 24 months b. 12 months d. 48 months PTS: 1 REF: 8 5. When planning an information system, a company must consider how a new system will interface with older systems, which are called ____. a. enterprise applications c. operating applications b. network operating systems (NOS) d. legacy systems PTS: 1 REF: 7 6. For complex operations, analysts apply computer-based modeling tools that use a standard language called ____. a. electronic data interchange (EDI) b. joint application development (JAD) c. business process modeling notation (BPMN) d. rapid application development (RAD) PTS: 1 REF: 14 7. Systems analysts use a......

Words: 21215 - Pages: 85

Premium Essay

System Analysis and Design

...software, the Internet, or the people that work with these technologies. 2. What is System Analysis & Design? * System analysis and design deal with planning the development of information systems through understanding and specifying in detail what a system should do and how the components of the system should be implemented and work together. 3. What is a System? Information? * System: a set of connected things or devices that operate together. * Information: Information is organised or classified data which has some meaningful values for the receiver. Information is the processed data on which decisions and actions are based. 4. (PDF SAVE AT DOWNLOADS) 5. Who is a System Analyst? * A systems analyst uses computers and related systems to design new IT solutions, modify, enhance or adapt existing systems and integrate new features or improvements, all with the aim of improving business efficiency and productivity. They must possess a high level of technical expertise and clear insights into current business practices. Depending on the employer, clients may be internal, e.g. departments within the same organisation, or external. They: * examine existing IT systems and business models; * analyse systems requirements; * undertake product development; * implement, configure and test feasible solutions. What are the duties of a System Analyst? 1) Provide staff and users with assistance solving computer......

Words: 316 - Pages: 2