Active Directory Federation Services and some other services like Zedmed API services are likely to stop after a power outage or accidental shutdown.
We can create a script to check the status of it and start if required.
Open Notepad, write below script, and change MyServiceName into your actual service name (such as adfssrv for Active Directory Federation Services):
for /F "tokens=3 delims=: " %%H in ('sc query "MyServiceName" ^| findstr " STATE"') do ( if /I "%%H" NEQ "RUNNING" ( REM Put your code you want to execute here REM For example, the following line net start "MyServiceName" ) )
Step 1: Create a batch file you wish to run and place it under a folder where you have enough permissions, for example, under C drive.
Step 2: Click on Start and under search, type in Task, and click open Task Scheduler.
Step 3: Select Create Basic Task from the Action pane on the right of the window
Step 4: Under Create Basic Task, type in the name you like and click Next.
Step 5: From the Trigger, select the option you like and click Next.
I chose Daily and clicked Next, which brought me to this screen.
Step 6: Then click on Start a Program and click Next.
Step 7: Now click on Browser and select the batch file you would like to run.
Step 8: Finally, click on Finish to create the Task.
Now that we have created a Task, we must make sure it runs with the highest privilege. Since we have UAC settings, we have to make sure that it should not fail if it does not bypass the UAC settings when you run the file.
So click on Task Scheduler Library.
Then double click on the Task you just created.
Step 9: Click on Run with Highest privilege, Run whether user is logged on or not, and change user or group to an local admin by clicking Change User or Group…
then click OK.
Step 10: Go to Triggers tab, double click the new daily trigger you created. tick Repeat task every: , in the dropdown after it, select how often you want it to check ( I selected 5 minutes), and select 1 day after for a duration of:
click OK, and Ok again, type the password for the admin user you selected in Step 9. Click Ok again to save the task.
Now you can stop the service and see if it start in 5 minutes.