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

Stopping dependant service via script server 2008

Hi,

I need to restart a Backup exec remote agent service on a Server 2008 every day and would like to use a script for this. Unfortunately there is another service which depends on the one mentioned above.

This results in a need for user input (a 'Y' and [enter]) to the dependant service to restart aswell. I've spent several hours trying to get the required input sent to the command prompt (mainly using .sendkeys), but somehow I can't get the command prompt window activated (tryed appactivate). I can get the required charaters sent if I manually active the command prompt window first.

Can anyone help me with this? I've added my final attempt at the script below (and yes, I'm very much a novice with scripting :) ). I've left out the part stoping the service, I'm just concentrating on sending the char.

option explicit
Dim objShell
set objShell = WScript.CreateObject("WScript.Shell")
objshell.run "cmd.exe /k title cmd"
wscript.sleep 2000
objshell.appactivate "cmd"
objshell.sendkeys "y"
0
farodane
Asked:
farodane
1 Solution
 
setasoujiroCommented:
it would be easier to go as follows:

net stop "dependant service name"
net restart "backup exec service"
net start "dependant service"

save as .bat
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

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