Next Topic

Previous Topic

Book Contents

executeExternalScript()

Note: A No Approved External Scripts message displays in the Choose the external script to execute drop-down list if no external scripts have been manually added to the Kaseya Server, as described below.

Executes a script written in VB.Net (.vb) or CSharp (.cs) on the Kaseya Server from the following file locations.

executeExternalScript() XML files can have any filename. You can have multiple scripts in one file. You can also have multiple files. The scripts referenced by an XML file should be stored in the same location as the XML file under a \Script folder.

Example of VB.Net Script

This script writes to a file if the file exists.

Dim FILE_NAME As String = "c:\temp\test.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
     Dim objWriter As New System.IO.StreamWriter( FILE_NAME )
     objWriter.Write( "Hello" )
     objWriter.Close()
End If

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\script\CreateFile.vb

Note: This example requires the creation of c:\temp\test.txt prior to execution. Also, the group IIS_IUSRS must have permissions to C:\temp.

Example of XML File

The XML should be structured like the following example, which includes 2 external scripts.

<?xml version="1.0" encoding="utf-8" ?>
<externalScriptList>
	<externalScriptDef label="First Script" fileName="createFile.vb">
	</externalScriptDef>
	<externalScriptDef label="Second Script" fileName="createFile2.vb">
	</externalScriptDef>
</externalScriptList>

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\VB.xml

Example of C#.Net Script


This script writes to a file if the file exists.

string FILE_NAME = "c:\\temp\\test.txt";
if (System.IO.File.Exists(FILE_NAME) == true) {
 System.IO.StreamWriter objWriter = new System.IO.StreamWriter(FILE_NAME);
 objWriter.Write("Hello");
 objWriter.Close();
}

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\script\CreateFile.cs

Note:: This example requires the creation of c:\temp\test.txt prior to execution. Also, the group IIS_IUSRS must have permissions to C:\temp.

Example of XML File


The XML should be structured like the following example, which includes 1 external script.

<?xml version="1.0" encoding="utf-8" ?>
<externalScriptList>
    <externalScriptDef label="Write to a file" fileName="CreateFile.cs">
    </externalScriptDef>
</externalScriptList>

Place the script file in this location:

<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0\CS.xml

Definitions