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.
<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\0
- Files stored in the 0
directory are available in every partition. (Default)<Kaseya_Installation_Directory>\xml\SDProcExecuteScript\1
- The 1
directory in this example matches partition ID 1. Files stored in a partition-specific directory are available only in that partition.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
label
- The name that displays in the drop-down list of available scripts to execute. Should be informative of what the script does. Required.filename
- The filename of the script. The script must be located in the same folder as the XML statement under a \Script
folder. Required.name
- The name of an additionalAssembly
. Each additionalAssembly
should have its own node in the XML statement. Optional.