Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Pete Sass
  Where is Pete Sass?
 Marathon, Ontario
 Canada
 Pete Sass
 To: Ken Blum
  Where is Ken Blum?
 Chicago
 Illinois - United States
 Ken Blum
 Tags
Subject: RE: Net Start , Net Stop "Yuri"
Thread ID: 50976 Message ID: 50993 # Views: 4 # Ratings: 0
Version: Not Applicable Category: Win32API programming
Date: Tuesday, September 07, 2004 6:46:53 PM         
   


> > Probably you can do something similar to this. For Sophos Anti-virus on Windows NT I did:
> >
> > *---------------Stop Sophos Anti-Virus Service
> > lltest=.t. && (appropriate Conditions go here)
> >
> > IF lltest
> > locomputer = getobject("WinNT://"+LEFT(SYS(0),AT(" ",SYS(0))-1)+",computer")
> > for each loservice in locomputer
> > WITH loservice
> > if upper(.Class) = 'SERVICE' ;
> > and "SOPHOS"$upper(.displayname) AND .Status = 4
> > .Stop
> > ENDIF
> > endwith
> > ENDFOR
> > ENDIF
> >
> >
> > * program body goes here ......
> >
> > *---------------Turn on Sophos Anti-Virus Service
> > IF lltest AND TYPE("locomputer")="O" AND NOT ISNULL(locomputer)
> > for each loservice in locomputer
> > WITH loservice
> > if upper(.Class) = 'SERVICE' ;
> > and "SOPHOS"$upper(.displayname) AND .Status # 4
> > .Start
> > ENDIF
> > endwith
> > ENDFOR
> > locomputer=.null.
> > ENDIF
> >
> >
> >
> > > Hi All
> > > Does anyone know if there is a API call to start and stop a service?
> > > Thanks
> > > A
>
> Yuri, this looks very interesting. When I tried it nothing shows for the properties/methods in loComputer. Where can I find some info on the object documentation to loComputer?
>
> KTB



Hi,
I too am interested in this.... I just did some recode to modify for a function type of call to play with:

FUNCTION StopServ
LPARAMETERS cServName

lltest=.F.

locomputer = getobject("WinNT://"+LEFT(SYS(0),AT(" ",SYS(0))-1)+",computer")
FOR EACH loservice IN locomputer
WITH loservice
If Upper(.Class) = 'SERVICE' ;
and cServName$upper(.displayname) AND .Status = 4
.Stop
lltest=.T.
ENDIF
ENDWITH
ENDFOR

RETURN lltest

So if I :
?StopServ("Messenger")
I should stop my messenger service ??????
I tried and does not stop the service.. am I missing something???
What are you actually getting with the getobject() call to WinNT://.... .... .... .... ???

Pete from the Great White North. (Only in Canada, ay.) Over and Out ...


ENTIRE THREAD

Net Start , Net Stop Posted by A QP @ 9/7/2004 3:18:06 PM
RE: Net Start , Net Stop Posted by Pete Sass @ 9/7/2004 5:04:46 PM
RE: Net Start , Net Stop Posted by Yuri Rubinov @ 9/7/2004 5:41:24 PM
RE: Net Start , Net Stop Posted by Ken Blum @ 9/7/2004 6:02:49 PM
RE: Net Start , Net Stop "Yuri" Posted by Pete Sass @ 9/7/2004 6:46:53 PM
RE: Net Start , Net Stop "Yuri" Posted by Yuri Rubinov @ 9/7/2004 9:48:23 PM
RE: Net Start , Net Stop "Yuri" Posted by Mz @ 9/11/2004 5:41:50 AM
RE: Net Start , Net Stop "Yuri" Posted by Yuri Rubinov @ 9/11/2004 8:12:57 PM
RE: Net Start , Net Stop "A" Posted by A QP @ 9/13/2004 4:42:25 PM
RE: Net Start , Net Stop Posted by Yuri Rubinov @ 9/7/2004 9:43:06 PM
RE: Net Start , Net Stop Posted by Mz @ 9/9/2004 9:38:59 AM