Script to start/restart service

Posted on 2008-11-19
Last Modified: 2012-05-05
I need a script that can be called by a Windows Schedule task. The script needs to do the following:

-Check to see if a process is running on the server.
-If process is running, don't do anything.
-Wait for the process to stop running.
-When process has stopped, stop a specific Service.
-Wait for Service to stop
-Restart Service

-Windows 2003 Server
-Let's call the process "process"
-Let's call the service "service"
-VBS script or some other code that can be run by a bat file, which in turn is run by a windows schedule task would be great.
Question by:isaacr25
    LVL 2

    Accepted Solution

    LVL 21

    Assisted Solution

    tasklist | find /i "process"
    IF ERRORLEVEL 1 GOTO WaitForProcessToStop
    net stop service
    net start service

    Open in new window


    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    731 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

    16 Experts available now in Live!

    Get 1:1 Help Now