IF-THEN-ELSE CommandsThe following is a summary of IF-THEN-ELSE parameters used in VSA scripts.
Using Variables Use variables to store values that can be referenced in multiple script steps. Variables are passed automatically to nested scripts.
IF Parameters Application is Running Checks to see if a specified application is currently running on the managed machine. If the application is running, the THEN statement is executed; otherwise, the ELSE statement is executed. When this option is selected from the drop-down list, the Enter the application name field appears. Check Registry Value After entering the registry path, the value contained in the key is returned. A check can be made for existence, absence, equality, or size differences. For example, A backslash character The available tests are:
Check Variable Enter a variable name, in the form
For the tests Evaluate Expression Enter an expression containing one or more variable names, in the form
Service is Running Determines if a service is running on the managed machine.
Test File Determines if a file exists on a managed machine. Enter the full path and filename. For example, entering Note: Environment variables such as Test File in Directory Path Enter the name of a file to see if it exists on the managed machine. Because a THEN or ELSE step must be executed prior to this IF test, Test File in Directory Path is only useful for scripts called by the THEN or ELSE step of a parent script. Test Registry Key Tests for the existence of a registry key. Test Registry Key differs from Check Registry Value since it can check for a directory level registry entry that only contains more registry keys (no values). True Selecting User Is Logged In Tests to see if a specific user or any user is logged in on the managed machine. Enter the user's logon name or leave the field blank to check for any user logged in. The THEN steps are executed if a user is logged in. The ELSE steps are executed if the user is not logged in. User Response is Yes Displays a dialog box on the managed machine with Yes and No buttons. Also carries out the ELSE statement if an administrator-configured specified amount of time has timed out. If Yes is selected by the user, the THEN statement is executed. If the selection times out or the user selects No, the ELSE statement is executed. This function requests the user's permission to proceed with the script. This query is useful for scripts that require a reboot of the managed machine before completion. Script variables, for example THEN-ELSE Parameters Operating System Detect When writing a THEN-ELSE statement, you can select the operating system the script will execute on. This parameter is useful when you want to write one script that can be executed on different operating systems. For example, directory paths in Windows and Macintosh can require different directory path syntax in order to work correctly. Creating two separate script steps within the same script for Close Application If the specified application is running on the managed machine, then that application is closed down. Delete File Deletes a file on a managed machine. Enter the full path and filename. Note: Environment variables are acceptable if they are set on a user's machine. For example, using a path Delete File in Directory Path Deletes the specified file located at the path returned using the Get Directory Path From Registry parameter. Delete Registry Key Delete the specified registry key and all its sub-keys. Delete Registry Value Delete the value stored at the specified registry key. Execute File Executes the specified file on the managed machine. This function replicates launching an application using the Run… command located in the Microsoft Windows Start menu. This function takes three parameters:
Execute File in Directory Path Same as Execute File except the location of the .exe file is located at the path returned from a Get Directory Path From Registry parameter. Note: Environment variables are acceptable if they are set on a user's machine. For example, using a path Execute Script Causes another named script to execute. Use this capability to string multiple IF-THEN-ELSE clauses together. If the script no longer exists on the KServer, an error message displays next to the script drop-down list. You can use this command to run a system script. Execute Shell Command Allows the script to pass commands to the command interpreter on the managed machine. When this command is selected, the field Enter the command to execute in a command prompt is displayed. Enter a command in the field. The command must be syntactically correct and executable with the OS version on the managed machine. Commands and parameters containing spaces should be surrounded by quotes. Since the command is executed relative to the agent directory, absolute paths should be used when entering commands. Note: Execute Shell Command opens a command prompt window on the managed machine to execute in. If you do not want a window opening on the managed machine, because it might confuse users, put all the commands into a batch file. Send that file to the managed machine using the Write File command. Then run the batch file with the Execute File command. Execute File does not open a window on the managed machine. Get Directory Path From Registry Returns a file path stored in the specified registry key. Use this command to fetch the file location. For instance, use this command to find the directory where an application has been installed. Get File Upload the file at the specified path from the managed machine. Be sure to enter a full path filename that you want to upload. The file is stored on the KServer in a private directory for each managed machine. Access the uploaded file using Scripts > Get File.
Get File in Directory Path Just like the Get File command but it adds the path returned from the Get Directory Path From Registry command to the beginning of the remote file path. Access the uploaded file using Scripts > Get File function. Get URL Returns the URL of a website page and stores it in a file. Get Variable Defines a new agent variable. When the script step executes, the system defines a new variable and assigns it a value based on data fetched from the managed machine's agent. Note: See Using Variables at the top of this topic for the types of variable values supported by the Get Variable parameter. Impersonate User Enter a username, password, and domain for the agent to log in with, when Execute as user... is specified using Execute File, Execute File in Directory Path or Execute Shell Command. Leave the domain blank to log into an account on the local machine. Pause Script Pause the script for N seconds. Use this command to give Windows time to complete an asynchronous task, like starting or stopping a service. Reboot Unconditionally reboots the managed machine. To warn the user first, preface this command with a User Response is Yes message. A User Response is Yes message prompts the user before rebooting their machine. Rename Locked File Renames a file that is currently in use. The file is renamed the next time the system is rebooted. The specified filename is a complete file path name. Rename locked file can also be used to delete a file that is currently in use if the destination is empty. The file is deleted when the system is rebooted. Rename Locked File in Directory Path Renames a file that is currently in use. The file is renamed the next time the system is rebooted. The specified file name is appended to the directory path. Rename locked file in directory path can also be used to delete a file that is currently in use if the destination is empty. The file is deleted when the system is rebooted. Schedule Script Schedules a script to be run. Optionally specifies the time to wait after executing this step before running the script and the specific machine ID to run the script on. You can use this command to run a system script. Send Email Sends an email to one or more recipients. Specifies the subject and body text of the email. Send Message Sends the entered message to a managed machine. Selecting Immediately displays a message dialog box immediately. Selecting After user clicks the flashing system tray icon flashes the agent system tray icon when a message is received. The message is displayed when the user clicks the icon. Send URL Sends the entered URL to a managed machine. Selecting Immediately launches the default web browser and the specified URL is displayed. Selecting After user clicks the flashing system tray icon flashes the agent system tray icon when a message is received. The URL is displayed in the default web browser when the user clicks the icon. Set Registry Value Writes data to the specified registry value. This function takes three parameters:
Use Credential Use the credentials set for the machine ID in Set Credential to execute a file or shell when Execute as user... is specified using Execute File, Execute File in Directory Path or Execute Shell Command. The Note: A script execution error is logged if a Set Credential script command encounters an empty username. Write Directory Writes a selected directory, including subdirectories and files, from Manage Files Stored on Server to the full path directory name specified on the managed machine. Write File Writes a file selected from a drop down list from Manage Files Stored on Server to the full path filename specified on the managed machine. Enter a new filename if you want the file to be renamed. Each time a script executes the Write File command, the agent checks to see if the file is already there or not by hashing the file to verify integrity. If not, the file is written. If the file is already there, the script moves to the next step. You can repeatedly run a script with Write File that sends a large file to a managed machine and know that the VSA only downloads that file once. Note: Environment variables are acceptable if they are set on a user's machine. For example, using the path Write File in Directory Path Writes the specified filename to the path returned from a Get Directory Path From Registry command. Write Script Log Entry Writes the supplied string to the script log for the agent executing this script. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Topic 674: Send Feedback. Download a PDF of this online book from the first topic in the table of contents. |