[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Batch as a service auto Restart

Posted on 2009-04-09
6
Medium Priority
?
1,129 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Justin_W_Chandler
ID: 24108649
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
ID: 24133856
Any news?
0
 
LVL 2

Author Comment

by:purpleoak
ID: 24159178
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:Justin_W_Chandler
ID: 24159741
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
ID: 24165709
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 1500 total points
ID: 24167306
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
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.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

650 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