Skip to content
CA Process Automation - 4.2.2
Documentation powered by DocOps

VBScript Example: WinGetInfo Script Operator

Last update December 11, 2014

The WinGetInfo script operator runs VBScript on a Windows touchpoint.

The script creates two indexed fields, HostList and OSList in the WinGetInfo operator dataset. The script:

  • Reads the source file line-by-line.
  • Assigns host names (strHost) to indexed values in sequential HostList fields. The numbering starts with 0 and finishes at one less than the number of rows that are read from the source file.
  • Assigns operating systems (strOS) to indexed values in sequentially numbered OSList fields. The numbering starts with 0 and finishes at one less than the number of rows that are read from the source file.

The script populates the oArgs.Item variable with the Parameters input area entries of the calling Run Script operator. The first entry populates oArgs.Item(0). The script assigns the number of rows it reads to the NumRowsRead operator dataset variable. The Wscript.sleep 30000 line pauses the operator for 30 seconds so the user can examine the folders and files created in the C2OSVD location. You would not include the Wscript.sleep 30000 line in a production script.

Dim oArgs

Dim oShell

Dim colProcessEnv

Dim objFSO

Dim objDir

Dim objFileIn

Dim objFileOut

Dim intCounter

Dim intExitCode

Dim strLine

Dim intSpacePos

Dim strHost

Dim strOS

on error resume next

set oArgs = WScript.Arguments

set oShell = WScript.CreateObject("WScript.Shell")

Set colProcessEnv = oShell.Environment("Process")

if oArgs.Count = 1 then     'must have the required argument    

                to proceed normally,    

                fails if more arguments are present 

   strSourceFile = oArgs.Item(0)

   Set objFSO = CreateObject("Scripting.FileSystemObject")

   Set objDir = objFSO.CreateFolder(colProcessEnv("C2OSVD"))

   Set objDir = objFSO.CreateFolder(colProcessEnv("C2OSVD") & "\HostList")

   Set objDir = objFSO.CreateFolder(colProcessEnv("C2OSVD") & "\OSList")

   intCounter = 0

   Set objFileIn = objFSO.OpenTextFile(strSourceFile, 1)

   Do Until objFileIn.AtEndOfStream

    strLine = objFileIn.ReadLine

    intSpacePos = InStr(strLine, " ")

    strHost = Left(strLine, intSpacePos - 1)

    strOS = Right(strLine, Len(strLine) - intSpacePos)

    Set objFileOut = objFSO.CreateTextFile(colProcessEnv("C2OSVD") & "\HostList\" & intCounter)

    objFileOut.Write strHost

    objFileOut.Close

    Set objFileOut = objFSO.CreateTextFile(colProcessEnv("C2OSVD") & "\OSList\" & intCounter)

    objFileOut.Write strOS

    objFileOut.Close

    intCounter = intCounter + 1

   Loop

   objFileIn.close

   Set objFileOut = objFSO.CreateTextFile(colProcessEnv("C2OSVD") & "\NumRowsRead")

   objFileOut.Write intCounter

   objFileOut.Close

   intExitCode = 0

else

   'Wscript.echo "bad argument or required argument NOT present"

   intExitCode = 5

end if

Wscript.sleep 30000

on error goto 0

Wscript.Quit intExitCode

Was this helpful?

Please log in to post comments.