• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 438
  • Last Modified:

Script to start/restart service

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

Details/Environment:
-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.
0
isaacr25
Asked:
isaacr25
2 Solutions
 
r_ShealyCommented:
0
 
AmazingTechCommented:
Hmmm...
:WaitForProcessToStop
tasklist | find /i "process"
IF ERRORLEVEL 1 GOTO WaitForProcessToStop
 
net stop service
net start service

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now