Solved

Batch as a service auto Restart

Posted on 2009-04-09
6
1,114 Views
Last Modified: 2013-12-26
I need to setup a batch file as a service. The batch is set to run its task sleep for 20 seconds then run the task again. i need to be able to set this as a service that starts when the server starts. Runs without a user having to login to the server, and if someone logs in and closes the batch file it automatically restarts. I have seen a few places about setting it as a service which i have done however i cant get it to start the script again if i close the batch file.
0
Comment
Question by:purpleoak
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Justin_W_Chandler
Comment Utility
When you run a batch script as a service, it invokes CMD.EXE, which will show up in your process list. As with any service, if you end the process, it will not automatically restart itself, unless it is restarted by another process.

What you need to do is go into the properties of that service (SERVICES.MSC) and in the tab at the top labeled "Recovery", select "Restart the service" for 1st, 2nd, and subsequent failures.
tmppic.jpg
0
 
LVL 6

Expert Comment

by:Justin_W_Chandler
Comment Utility
Any news?
0
 
LVL 2

Author Comment

by:purpleoak
Comment Utility
Restarting the computer isnt really all that helpful as the server needs to be on all the time. This script checks certain tasks and copies files from a to b. sorry
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Expert Comment

by:Justin_W_Chandler
Comment Utility
NO, you need to select the drop down box. There is an option to restart the service, as I indicated in my notes. Here is another screenshot showing all the options.
ss.JPG
0
 
LVL 2

Author Comment

by:purpleoak
Comment Utility
It doesnt restart the script if i close it. I have tried this but it didnt seam to restart it, even if i set restart after 1 min, 1 hour etc.
0
 
LVL 6

Accepted Solution

by:
Justin_W_Chandler earned 500 total points
Comment Utility
If someone with administrator priviledges logs in, they will have the ability to close or stop ANY service. If the problem you're having is people stopping the service (or closing the service in task manager), you can't do anything to circumvent that. Preventing that sort of interaction is part of good security administration.

There is really only three ways you can help prevent this, however. One is to create a second service that monitors the first. If the first is closed, it would restart it. Frankly, if the user is savy enough about it, this trick may not work because they will simply close both services.

The second involves a little bit trickier method -- create a dependency for winlogon under this service. Then, if they close that service the machine will log them off. After closing the service (resulting in them being logged off) a couple of times, they'll get the idea and leave it alone. AGAIN, however, with administrator privileges, they can simply remove the dependency and then close the service.

The third, which is probably the most effective -- is to create a service on another machine that people haven't access too. This service would periodically poll any machines that are supposed to have that service running, and restart it if necessary.

My friend, what you need to do is implement an appropriate security model that will prevent the users' ability to close the application. I know this is not the answer you were hoping for but that's as simple as it gets.

Justin Chandler
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now