Develop a NetLogic that shuts down the host system
Create a NetLogic that immediately shuts down the host Windows® system on which the FactoryTalk Optix Application runs.
Prerequisites
Set the default external code editor. See Set the default code editor.
To develop a NetLogic that shuts down the host system
- In Project view, right-click NetLogic and select .
-
Hover-over the NetLogic, select
, and enter ShutDownSystemNetLogic
-
Double-click the NetLogic.
The external code editor opens.
-
Replace the existing code with the following code:
#region StandardUsing using System; using FTOptix.Core; using FTOptix.CoreBase; using FTOptix.HMIProject; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.NetLogic; using FTOptix.OPCUAServer; using FTOptix.UI; using System.Diagnostics; #endregion public class ShutDownSystemNetLogic : FTOptix.NetLogic.BaseNetLogic { [FTOptix.NetLogic.ExportMethod] public void SystemShutDown() { var psi = new ProcessStartInfo("shutdown", "/s /t 0"); psi.CreateNoWindow = true; psi.UseShellExecute = false; Process.Start(psi); } }
- Save the code.