Link to home
Start Free TrialLog in
Avatar of Lee W, MVP
Lee W, MVPFlag for United States of America

asked on

Shell & Service Issues

First, I'm not a programmer - I dabble and know a bit (DLL calls I do NOT know).

Trying to write a program that monitors services under NT.
In order to verify that the service exists and/or is running, I was going to use a shell command and redirect the output to a file - open that file and parse the information.  Problem is, the NET START <service> command will not redirect to a file.  So I need an alternate way of doing this - simple DLL calls (well detailed in any perspective answer), another way of reading the result of information from the shell, whatever.  The following is more or less how I was intending to do this, assuming the redirection worked:

shell "net start " + ServiceName + " > ~svcchk.tmp"
open "~svcchk.tmp" for input as #1
line input #1, StartServiceResult
If instr(StartServiceResult, <string>) then
else
end if
ASKER CERTIFIED SOLUTION
Avatar of Mirkwood
Mirkwood

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Lee W, MVP

ASKER

I'll grade this tonight - I'll make it an "A" if you provide the source of your code (Technet, URL, etc).  Otherwise, it'll probably be a B (or C if it turns out its too cumbersome/time consuming for me to "decode" (it seems to do what I want it to, but it also seems to have a lot of things I'm not looking for - and I'd have preferred more comments to explain what exactly is being done everywhere).
Avatar of Mirkwood
Mirkwood

I'm afraid the human brain is the source.

But how difficult can it be:

vbStartService
ServiceStatus
vbPauseService
vbStopService

The parameters are always computername, servicename

Ok... acceptible... though I did have some initial problems (vb6) having the constants as public - I had to remove the public portion of those statements and it worked.  Though I suppose it could just have something to do with how I had things.  I got it working though (or so it would seem) - but it doesn't seem to work with the SERVER or WORKSTATION services (I'll need to do a bit of further testing - I'm also running vb6 on win2k).  I'm going to delay answering the question just yet - you'll get the points at either an A or B grade, depending on how easily I figure out the rest of it (I think it'll be ok, but just want to check).
That's because it's a module not a form. Forms don't allow public constants and declarations.