This post with the code snippet helps you how to access the status of any windows services using X++. Also, it is easy to start and stop windows services programmatically.
Before you start running the code, you need to add reference System.ServiceProcess from the AOT references node.
Note : Get_status() method is used to get the status of the service. Code can be modified according to the status of the service.
static void
start_stop_Service(Args _args)
{
System.ServiceProcess.ServiceController controller = new
System.ServiceProcess.ServiceController();
;
controller.set_MachineName(‘.’);
controller.set_ServiceName("IISADMIN");
controller.Stop();
sleep(500);
controller.Start();
}
Before you start running the code, you need to add reference System.ServiceProcess from the AOT references node.
Note : Get_status() method is used to get the status of the service. Code can be modified according to the status of the service.
static void
start_stop_Service(Args _args)
{
System.ServiceProcess.ServiceController controller = new
System.ServiceProcess.ServiceController();
;
controller.set_MachineName(‘.’);
controller.set_ServiceName("IISADMIN");
controller.Stop();
sleep(500);
controller.Start();
}