Skip to end of banner
Go to start of banner

How to run external executable within BVMS SDK scriplet?

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

Version 1 Next »

Article status

EXTERNAL 

Link to be provided outside of Bosch

Question

How to run external executable within BVMS SDK scriplet?

Answer

For more details about how to execute scriplets in the BVMS SDK, please check:


Call .bat files scriplet:

// ScriptType: ServerScript
// ScriptLanguage: CS

using System;
using System.Diagnostics;
using System.Collections.Generic;
using log4net;
using Bosch.Vms.Core;
using Bosch.Vms.SDK;
using System.Net;

[BvmsScriptClass()]
public class ServerScript : IDisposable
{
    private readonly IServerApi Api;
    private readonly ILog Logger;    
    
    public ServerScript(IServerApi api)
    {
        this.Logger = LogManager.GetLogger("ServerScript");
        this.Api = api;        
    }

    public void Dispose()
    {
        // Use this method to cleanup any resources here (consider fully implementing the Dispose pattern).
        // For example, stop and dispose any started timers. Ensure that all threads that were started are stopped here.
        // DO NOT BLOCK in this method for a very long time, as this may block the applications current activity.
    }
    


    [Scriptlet("dbb99725-39ee-4bcf-972c-2f270aea727d")]
    public void CamerasON(EventData e)
    {
        string fullBatPath = @"C:\scripts\cameras_ON.bat";

        var process = new Process()
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "cmd.exe",
                Arguments = $"/C \"{fullBatPath}\"",
                UseShellExecute = false,
                CreateNoWindow = false,
            }
        };
        process.Start();
    }

    [Scriptlet("c8d87b59-846f-4d35-bdfe-e96707a00256")]
    public void CamerasOFF(EventData e)
    {
        string fullBatPath = @"C:\scripts\cameras_OFF.bat";

        var process = new Process()
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "cmd.exe",
                Arguments = "/C \"{fullBatPath}\"",
                UseShellExecute = false,
                CreateNoWindow = false,
            }
        };
        process.Start();
    }
}




ADVANCED section

Please contact CTS / SG or GK team to view this section from draft space, if necessary


Information below is for CTS, SG, GK reference and must be kept internal only.

If you are part of CTS, SG or GK team, please hide this section when you have finished using this article!


This section will not be published externally and / or automatically downloaded in the PDF file!



  • No labels