Search This Blog

Loading...

Friday, 5 June 2009

Remotely start/stop WatchDirectory and WatchFTP services

A great free tool from Sysinternals (now owned by Microsoft) is the psexec program. With psexec you can run programs on other computers and it supports full interaction with remote command prompts. This allows you, for example, to start or stop Windows Services by running the "NET START" or "NET STOP" command.

Initial Setup

I always create a new user on the computer I want to access with psexec and name it psexec as well. I give this user administrator privileges so it can do "whatever I want". This step may not be necessary, see the psexec help (just run psexec without parameters).

Control a Service on another machine

Okay, lets assume I want to stop the WatchDirectory task "unzipbiggies" that runs as a Service on computer \\Test01. First, you need to know that when WatchDirectory creates a Windows Service, the Service name is prefixed with "watchDirectory:", so the actual Windows Service name for the task "unzipbiggies" is "watchDirectory:unzipbiggies".
WatchFTP prefixes Service names with the string "WatchFTP:".

First we need to open a command prompt on the remote computer:

C:\Users\gert>e:\bin\psexec.exe \\Test01 -u psexec -p topsecret cmd

This assumes you created a user "psexec" with password "topsecret" on the \\Test01 computer.

After a while this opens a command prompt on the remote computer, but it shows on your computer. Enter the following command to see all running Windows Services (including the WatchDirectory and WatchFTP services):

C:\Users\gert>NET START
These Windows services are started:

... snipped a lot of services....
   Terminal Services
   Themes
   UPnP Device Host
   User Profile Service
   watchDirectory:unzipbiggies
   wdPostMan
   WebClient
   Windows Audio
   Windows Audio Endpoint Builder
... snipped a lot of services....
The command completed successfully.

To stop the WatchDirectory task, enter

C:\Users\gert>NET STOP "watchDirectory:unzipbiggies"

To start the task again, enter

C:\Users\gert>NET START "watchDirectory:unzipbiggies"

Other uses

There are a lot of other things you can do with psexec. For example when a file is detected by WatchDirectory on "this" computer, let psexec run a command on another computer. You get the idea, I guess.

No comments: