Free Essay

System Analysis and Design

In:

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

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 assessment:...

Words: 2100 - Pages: 9

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 collaboratively...

Words: 11373 - Pages: 46

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

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, resolution...

Words: 297 - Pages: 2

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 related problems...

Words: 316 - Pages: 2

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

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 “Compatibility...

Words: 1880 - Pages: 8

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 diagrams...

Words: 1673 - Pages: 7

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 whole. Table...

Words: 731 - Pages: 3

Premium Essay

System Analysis and Design

...System planning involves strategic analyzing of how company will fit to the system that will proposed by the analyst. There are several factors that should be considered in doing a system: The problem, scope, gathering information, the feasibility, the development and recommendation. These factors serve as a guide to build a system proposed. By focusing in the needs of company and its clients; we must say we develop a system not only for our clients and to the business but for the contribution of satisfaction of their customers. This study is based on the process in creating System Analysis and Design. It follows procedure and it is based on fact of our client information. Introduction A Study involves processes that provide information to develop a system. A Computer System that can help the company in their transactions. In accordance to our study, we investigated a company that manually operates the transactions of their customers. Our respected company is Umali Surgical and Animal Bite Clinic. Is a resident surgical and animal bite clinic has a registered nurse, A General and Cancer Surgeon that appoints and give their services to the clients. The Clinic locates at 44 M.H.delPilar St. Tugatog, Malabon City. The owner is Dr. Ismael C. UmaliIII. He is a General and Cancer Surgeon and also appoints his clients in a private way of giving services. Shiela Ann Pidong,a registered nurse. We founded out that their transaction is manually operated by...

Words: 298 - Pages: 2

Premium Essay

System Analysis Design

...A number of system development life cycle models have been created for support an improvement of an organisation these are; fountain, waterfall, spiral, agile RAD- Rapid Application Development. One of the oldest is the waterfall: a sequence of stages in which the output of each stage becomes the input for the next. RAD- rapid application development Fountain Spiral Agile These stages can be characterized and divided up into different ways such as; Feasibility study enabling a high level view of intended project and determine its goal System analysis: Analysing end users information needs and defining project goals in terms of functionality and operation of intended project System design: Describes desired features and operation in detail, including screen layout business rules, process diagram and other documentation. Implementation Integration and testing: Brings all the pieces together into special testing environment, then checks for errors and bugs. Acceptance: The final stage of initial development, where the software is put into production and runs actual business. Maintenance: What happens during the rest of software’s life: changes, correction, additions, moves to different computing platform and more. The importance of following a procedural/staged life cycle in a system investigation is The role played in information systems development by the system analyst The importance of linking information system to business needs are; In general...

Words: 434 - Pages: 2

Premium Essay

Systems Analysis and Design

...CASE: PETRIE’S ELECTRONICS Systems Planning and Selection Now that the “No Costumer Escapes “project team has been formed and a plan has been developed for distributing project information, Jim began working on the project scope statement,workbook,and baseline project pan. He first drafted the project scope statement and posted it on the project’s intranet (see PE Figure 4-1).Once posted on the intranet, he sent a short e-mail, Jim’s office phone rang. “Jim, it’s Sally. I just looked over the scope statement and have a few comments.” “Great, “replied Jim, “it’s just a draft. What do you think?” “Well,I think that we need to explain more about how the system will work and why we think this new system will more than pay for itself.” “Those are good suggestions; I am sure many others will also want to know that information. However, the scope statement is a pretty high-level document and doesn’t get into too much detail. Basically, it’s purpose is to just formally announce the project, providing a very high-level description as well as briefly listing the objectives, key assumptions, and stakeholders. The other documents that I am working on, the workbook and the baseline project plan are intended to provide more details on specific deliverables, costs, benefits, and so on. So, anyway, that type of more detailed information will becoming next.” “Oh, OK, that makes sense. I have never been on a project like this, so this is all new to me,” said Sally. “Don’t worry, “replied...

Words: 900 - Pages: 4

Premium Essay

System Analysis and Design

...Acknowledgment First of we would like to thank our Almighty God. We would like to thank our instructor Solomon for giving us this chance. It was more helpful to know about the course. We would to extend our deep gratitude to Ato Endeshaw for his help in offering us the resources in this study. Last but not least, we would like to thank the company staffs for providing relevant information about the company. Acronyms SRS – Software Requirement Specification GRV- Goods Receiving Voucher SQL- Structured Query Language DBMS- Data Base Management System TABLE OF CONTENT Page 1. Organizational Background----------------------------------------------- 4 2. Current Information System----------------------------------------------- 5 3. Problems----------------------------------------------------------------------- 8 4. Feasibility of the study------------------------------------------------------ 8 5. Project Plan--------------------------------------------------------------------9 6. Requirements-----------------------------------------------------------------11 7. Modelling-----------------------------------------------------------------------23 8. Decision Table----------------------------------------------------------------26 9. E-R Diagram------------------------------------------------------------------27...

Words: 2783 - Pages: 12

Premium Essay

System and Analysis Design

...Republic of the Philippines Cavite State University Don Severino De las Alas Campus Indang, Cavite COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY In Partial Fulfillment of ITEC 55: Systems Analysis and Design (SAD) Baby Dolphin’s Social Learning Network for the Elementary Department of Philippine Christian University Dasmarinas Campus Submitted to: Edilberto O. Solis Jr. Instructor Submitted by: Bansale, Joseph B. Mendoza, Jennina L. Vega Blessed Joy A. Date submitted: September 30, 2013 I. Introduction Background of the Study Learning Management System (LMS) is responsible for “learning” activities. Online learning tasks can be performed at any time or place provided they have Internet access. Online learning environments thus differ significantly from traditional learning environments, where teachers and students must meet regularly at a specific place and time. Online learners become more free, flexible and convenient in time and location of learning. The Philippine Christian University (PCU) elementary school had truly gone a long way it had when it first opened in 1971. Today, it boasts of considerable increase in number of pupils and teachers, as well, thus fulfilling the dreams of the founders of the institution. Indeed, it is a legend turned into reality! Elementary Department indeed is pride and big assets of Philippine Christian University as a whole. Just like any other school...

Words: 4498 - Pages: 18

Premium Essay

Systems Analysis and Design

...high, often because of competition and incompatibility between enabling products. SAP NetWeaver comprises the following key capabilities: • Key capabilities of People Integration: o Multi-Channel Access o Portal o Collaboration • Key capabilities of Information Integration: o Business Intelligence o BI Content & BI Content Extensions o Knowledge Management o Master Data Management • Key capabilities of Process Integration: o Integration Broker o Business Process Management • Key capabilities of Application Platform: o Cross-platform services o ABAP Engine o Virtual Machine Controller o Java Engine o Business Services 2. How can NetWeaver help Fitter? NetWeaver can help because Amy would be able to log into the SAP system from home and do her job. SAP also has an enterprise portal that can be tailored to each user based on their job. This will reduce the clutter and confusion that can be a problem. SAP has mobile infrastructure that allows Donald to be able to confirm promise ship dates. He is also able to call up some reporting in NetWeaver that shows trends on which snack bar would be the best selling nationwide. He can also use data mining to help find patterns that allow him to forecast better. 3. What is software as a service (SaaS)? Software as a Service (SaaS) is a software distribution model in which applications are hosted by a vendor or service provider and made available to customers...

Words: 382 - Pages: 2