Functions COM Object Methods

This article contains the following topics:
casm171
This article contains the following topics:
The following Functions COM Object Methods are available for use in Support Automation automated tasks.
Function
Description
B64Encode (BSTR data, VARIANT *varResult)
Base64 encodes the specified data.
B64Decode (BSTR data, VARIANT *varResult)
Decodes the specified data.
CheckIfServerExists (BSTR URL, USHORT port, VARIANT *varResult)
Makes a request on the specified server to determine if it is accepting connections.
Eof (LONG fileno, VARIANT *varResult)
Determines if there is unread data in the specified text file
EscalateToLive (VARIANT *varResult)
Escalates the customers session from Self-Serve to Live Session
ExecuteRC (BSTR MethodName, BSTR ParamStr, int ParamCount, VARIANT *varResult)
Executes a RuleConduit call on the server allowing arbitrary server methods to be executed.
ExecuteWaitAndCaptureStream (BSTR strProg, int nStream, VARIANT *varResult)
Executes the specified command and waits for the process to exit, capturing the output from the process execution.
FileAddAttributes (BSTR szFilePath, LONG dwAttr, VARIANT *bvarResult)
Call to add attributes (Read-Only, Compressed, Archived, etc…) to a file without changing attributes already there.
FileCloseTextFile (LONG fileno)
Closes a text file previously opened with FileCreateTextFile or FileOpenTextFile.
FileCopyTo (BSTR szSourceFilePath, BSTR szDestFilePath, VARIANT_BOOL bcanOverwrite, VARIANT *bvarResult)
Call FileCopyTo to copy a file from one place to another.
FileCreateTextFile (BSTR szFilePath, BOOL overwrite, VARIANT *varResult)
Creates a new text file in the specified location returning a handle that can be used to interact with the file.
FileDelete (BSTR szFilePath, VARIANT *bvarResult)
Call to permanently delete a file.
FileExecute (BSTR szCommand, VARIANT *bvarResult)
Call to execute a file.
FileExecuteAndWait (BSTR szCommand, LONG dwMilliseconds, VARIANT *bvarResult)
Call to execute a file and wait for it to exit.
FileExists (BSTR szFilePath, VARIANT *bvarResult)
Checks whether a file exists or not.
FileGetAttributes (BSTR szFilePath, VARIANT *dwvarResult)
Call to retrieve the attributes (Read-only, archive, compressed, etc…) of a file.
FileGetDirectoryContents (BSTR pathName, BOOL showFiles, BOOL showDirs, VARIANT *varResult)
Returns the selected contents of the specified directory.
FileGetDrives (VARIANT *varResult)
Call to get a list of drives mounted.
FileGetDriveType (BSTR driveName, VARIANT *varResult)
Returns the type of the specified drive.
FileGetInfo (BSTR szFilePath, VARIANT *varResult)
Call to get the size and date information for a file.
FileGetINISectionContents (BSTR filename, BSTR sectionName, VARIANT *varResult)
Gets a pipe delimited list of the contents of the specified INI section.
FileGetINIValue (BSTR fileName, BSTR sectionName, BSTR keyName, BSTR defaultValue, VARIANT *varResult)
Gets the value of the specified item in the INI file.
FileGetInternetFile (BSTR szURL, BSTR szFilePath, VARIANT *bvarResult)
Call to download a file from the internet.
FileGetSize (BSTR szPath, VARIANT *varResult)
Gets the size of a file in bytes.
FileGetVersion (BSTR szFilePath, VARIANT *szvarResult)
Retrieves the version number of a file.
FileGetVolumeInfo (BSTR szVolumeRootPath, VARIANT *varResult)
Gets the information for a drive.
FileMakeDir (BSTR szDirPath, VARIANT *bvarResult)
Creates a directory.
FileMoveTo (BSTR szSourceFilePath, BSTR szDestFilePath, VARIANT_BOOL bcanOverwrite, VARIANT *bvarResult)
Moves a file from one place to another.
FileOpenTextFile (BSTR szFilePath, BSTR szMode, VARIANT *varResult)
Opens the specified text file returning a handle that can be used to interact with the file.
FileReadLine (LONG fileno, VARIANT *varResult)
Reads a line of text from the text file.
FileRecycle (BSTR szFilePath, VARIANT *bvarResult)
Recycles a file. Recycling places the file in the recycle bin and removes it from its original folder.
FileRenameTo (BSTR szSourceFilePath, BSTR szDestFilePath, VARIANT_BOOL bcanOverwrite, VARIANT *bvarResult)
Call FileRenameTo to change the name of a file.
FileSetAttributes (BSTR szFilePath, LONG dwAttr, VARIANT *bvarResult)
Sets the attributes (Read-only, archived, compressed, etc…) of a file.
FileSetINIData (BSTR filename, BSTR sectionName, BSTR keyName, BSTR data, VARIANT *varResult)
Sets the data for the specified key in the INI file.
FileWriteLine (LONG fileno, BSTR value, VARIANT *varResult)
Writes a line of text into the text file.
GetChildWindowCaption (int index, VARIANT *varResult)
Gets the caption for the specified child window.
GetChildWindowHandle (int index, VARIANT *varResult)
Gets the handle for the specified child window.
GetChildWindowProcessName (int index, VARIANT *varResult)
Gets the name of the process that owns the specified child window.
GetChildWindows (int hwnd, VARIANT *varResult)
Enumerates the windows that are children of the specified window storing the results for future querying, returning the count.
GetExecutionEnvironment (VARIANT *varResult)
Gets a string indicating where the script is being executed.
GetLocalization (VARIANT *varResult)
Gets the localization of the current user.
GetRootUrl (VARIANT *result)
Return the Server Root URL.
GetStaticContentUrl (VARIANT *result)
Return the Server Static Content URL.
GetStaticItemURL (BSTR itemGuid, VARIANT *varResult)
Retrieves the root URL of the given static content item.
GetSupportDeskOpen (VARIANT *varResult)
Gets the hours of operation status of the support desk.
GetWindowCaption (int index, VARIANT *varResult)
Gets the caption for the specified window.
GetWindowHandle (int index, VARIANT *varResult)
Gets the handle for the specified window.
GetWindowProcessName (int index, VARIANT *varResult)
Gets the name of the process that owns the specified window.
GetWindows (VARIANT *varResult)
Enumerates the system top level window handles, stores the results for future calls and returns the count.
HttpGet (BSTR szUrl, VARIANT *varResult)
Makes a request on the specified URL and returns the results.
HttpPost (BSTR szUrl, BSTR szBody)
Posts the specified request body to the specified URL.
InternetCheckConnection (VARIANT *varResult)
Determines if the customer machine appears to have a working internet connection.
LogMessage (BSTR szMessage)
Adds a message to the session log for the script execution.
OutlookGetPSTContents (BSTR szPSTPath, VARIANT *varResult)
Gets the contents of the specified Outlook PST file.
PromptUser (LONG Timeout, BOOL DefaultResult, BSTR Message, VARIANT *varResult)
Prompts the user with given message.
ReadLine (LONG fileno, VARIANT *varResult)
Reads a line of text from the text file. (deprecated, use FileReadLine instead).
RegCopyKey (BSTR szSourceRoot, BSTR szSourceKey, BSTR szDestRoot, BSTR szDestKey, VARIANT_BOOL bCanOverwrite, VARIANT *varResult)
Copies the entire contents of one key to another.
RegCopyValue (BSTR szSourceRoot, BSTR szSourceKey, BSTR szSourceValue, BSTR szDestRoot, BSTR szDestKey, BSTR szDestValue, VARIANT *bvarResult)
Copy the contents of one key/value to another. The user must have the ability to query keys for the root specified.
RegCreateKey (BSTR szRootPath, BSTR szKeyPath, VARIANT *bvarResult)
Creates a key entry in the user's registry.
RegDeleteKey (BSTR szRootPath, BSTR szKeyPath, VARIANT *bvarResult)
Removes a key from the registry. The user must have the ability to remove keys from the root specified.
RegDeleteValue (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, VARIANT *bvarResult)
Removes a key value from the registry. The user must have the ability to query keys for the root specified.
RegGetDWORD (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, VARIANT *dwvarResult)
Retrieves the a DWORD value from a specified key in the registry. The user must have the ability to query keys for the root specified.
RegGetString (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, VARIANT *szvarResult)
Retrieves a string value from a registry key. The user must have the ability to query keys for the root specified.
RegGetSubkeyByIndex (BSTR szRoot, BSTR szKey, LONG idxSubkey, VARIANT *varResult)
Retrieves the name of a subkey based on its index. The user must have the ability to query keys for the root specified.
RegGetSubkeysCount (BSTR szRoot, BSTR szKey, VARIANT *varResult)
Gets the number of keys underneath any given key. The user must have the ability to query keys for the root specified.
RegGetValueByIndex (BSTR szRoot, BSTR szKey, LONG idxValue, VARIANT *varResult)
Retrieves a key value given its index. The user must have the ability to query keys for the root specified.
RegGetValuesCount (BSTR szRoot, BSTR szKey, VARIANT *varResult)
Gets the number of values for a given key. The user must have the ability to query keys for the root specified.
RegGetValueType (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, VARIANT *dwvarResult)
Finds out the type of value for a given Registry key. The user must have the ability to query keys for the root specified.
RegKeyExists (BSTR szRootPath, BSTR szKeyPath, VARIANT *bvarResult)
Queries a key from the registry. The user must have the ability to query keys from the root specified.
RegMoveKey (BSTR szSourceRoot, BSTR szSourceKey, BSTR szDestRoot, BSTR szDestKey, VARIANT_BOOL bCanOverwrite, VARIANT *varResult)
Moves the entire contents of one key to another.
RegMoveValue (BSTR szSourceRoot, BSTR szSourceKey, BSTR szSourceValue, BSTR szDestRoot, BSTR szDestKey, BSTR szDestValue, VARIANT *bvarResult)
Moves the contents of one key value to another. The user must have the ability to query keys for the root specified and write to the destination.
RegRenameValue (BSTR szRootPath, BSTR szKeyPath, BSTR szOldValueName, BSTR szNewValueName, VARIANT *bvarResult)
Changes the name of a registry value. Note: The user must have the ability to query keys for the root specified.
RegRestoreKeyFromFile (BSTR szRootPath, BSTR szKeyPath, BSTR szFilePath, VARIANT *bvarResult)
Restores the entire contents of a key from a file into the registry. The user must have the ability to query and write keys for the root specified.
RegSaveKeyToFile (BSTR szRootPath, BSTR szKeyPath, BSTR szFileName, VARIANT *bvarResult)
Saves the entire contents of a key from the registry into a file. This file may then be restored using RegRestoreKeyFromFile. The user must have the ability to query keys from the root specified.
RegSetDWORD (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, LONG dwValue, VARIANT *bvarResult)
Sets a DWORD value in the registry. The user must have the ability to query keys for the root specified.
RegSetString (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, BSTR szValue, VARIANT *bvarResult)
Sets a string value for a key in the registry. The user must have the ability to query keys for the root specified.
RegValueExists (BSTR szRootPath, BSTR szKeyPath, BSTR szValueName, VARIANT *bvarResult)
Checks for the existence of a key/value pair in the registry. The user must have the ability to query keys for the root specified.
RunCommandAsImpersonatedUser (BSTR bapp, BSTR bargs, VARIANT_BOOL block, LONG timeout, VARIANT *varResult)
Runs an application with the same credentials the script has (deprecated). Returns 0 on success.
RunCommandAsUser (BSTR domain, BSTR user, BSTR password, BSTR app, BSTR args, VARIANT_BOOL block, LONG timout, VARIANT *varResult)
Runs an application as another user. Returns 0 on success.
SaveLog (BSTR fileName)
Saves the session log.
SendEmail (BSTR toAddress, BSTR emailSubject, BSTR emailBody)
Sends an email via CA Service Desk Manager mail daemon.
SetAcquiredData (BSTR data)
Save a chunk of script specific character data on the server for later use.
SetScriptSuccess (BOOL bSuccess, VARIANT *varResult)
Indicates whether the script executed successfully from the script's point of view.
ShowFileBrowseDlg (BSTR browseType, BSTR fileExt, VARIANT *varResult)
Shows the standard windows file browse dialog and returns the selected file.
ShowMessage (BSTR szMessage)
Displays the message to the user in a message box.
Sleep (LONG time)
Causes the execution thread to sleep.
TransferToQueue (BSTR queueID, BSTR queueName)
Sets the customer's current queue, this is the queue that the customer will enter if escalated to live.
UtilAttachDll (BSTR szDllPath, BSTR szHTTPLocation, VARIANT *varResult)
Loads a dll into the process space so that functions may be called from it.
UtilCloseTask (BSTR szProcName, VARIANT *bvarResult)
Closes a running task.
UtilDetachDll (LONG idDll, VARIANT *varResult)
Unloads a DLL from memory.
UtilEndProcess (BSTR szProcName, VARIANT *bvarResult)
Terminates the process with the specified name.
UtilExitWindows (LONG lAction, VARIANT_BOOL bForce, VARIANT_BOOL bRelogin)
Exits windows either by log off, restart, or shutdown.
UtilExternalMethodCall (LONG idDll, BSTR szFuncName, LONG lFuncType, BSTR szParams, VARIANT *varResult)
Executes a function from a loaded DLL.
UtilGetComputerName (VARIANT *varResult)
Gets the current computer name.
UtilGetEnvironmentVariable (BSTR szVarName, VARIANT *varResult)
Gets the value of a defined environment variable.
UtilGetOSVersion (VARIANT *varResult)
Gets the OS version.
UtilGetProcessByIndex (LONG idxProcess, VARIANT *varResult)
Retrieves process information for the specified process.
UtilGetProcesses (VARIANT *varResult)
Gets a list of all processes running on the customer machine.
UtilGetProcessesCount (VARIANT *varResult)
Gets the number of processes currently running on the customer machine.
UtilGetProcessMemory (LONG processID, VARIANT *varResult)
Gets the amount of memory used by the specified process.
UtilGetRunningTask (LONG idxWnd, VARIANT *varResult)
Gets information related to a task running on the customer machine. UtilGetRunningTasksCount should be called first to determine the number of tasks available.
UtilGetRunningTasksCount (VARIANT *varResult)
Gets a count of the tasks running on the customer machine.
UtilGetSystemDir (VARIANT *varResult)
Gets the windows system directory.
UtilGetSystemMetrics (LONG nIndex, VARIANT *varResult)
Gets the value of the specified system metric.
UtilGetUserName (VARIANT *varResult)
Gets the current user's logon name.
UtilGetWindowsDir (VARIANT *varResult)
Gets the directory for windows.
UtilGlobalMemoryStatus (VARIANT *varResult)
Gets information on global memory availability.
 
WScript
Many public domain script examples are available from sources such as Microsoft TechNet ScriptCenter, which are typically aimed at a system administrator audience, but are often useful for use in automated tasks. They often assume that the existence of an object called WScript, which Microsoft provides as part of their command-line script execution engine, but not part of the Windows Script Host in itself.
CA SDM implements a simple version of the WScript object providing the Echo, Sleep, GetObject, and CreateObject methods, providing compatibility for the most commonly used WScript methods. WScript.Echo(), which usually writes to the command line, is implemented in CA SDM to write to the automated task log, and thus WScript.Echo() is synonymous with Functions.LogMessage().