Page 1 of 1 1
Topic Options
#139387 - 2005-05-09 04:17 AM stopservices() & startservices()
Brant_Winter Offline
Fresh Scripter

Registered: 2005-05-08
Posts: 26
Hi - In response to help from a couple of guys in the firums here I managed to create a UDF to stop services on a remote server.

Code:

FUNCTION STOPSERVICES($SVR, $Service)
$AD=GetObject("WinNT://"+$SVR+",computer")
$AD1= $AD.GetObject("Service",$service)
$SVCSTAT = $AD1.Status
IF $SVCSTAT <> 1
$STOPIT = $AD1.Stop
$SVCSTAT = $AD1.Status
ENDIF
ENDFUNCTION




Similarly the start() function:

Code:

FUNCTION STARTSERVICES($SVR, $Service)
$AD=GetObject("WinNT://"+$SVR+",computer")
$AD1= $AD.GetObject("Service",$service)
$SVCSTAT = $AD1.Status
IF $SVCSTAT <> 4
$STOPIT = $AD1.Start
$SVCSTAT = $AD1.Status
ENDIF
ENDFUNCTION



Edited by Brant_Winter (2005-05-09 04:18 AM)

Top
#139388 - 2005-05-09 04:33 AM Re: stopservices() & startservices()
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Please follow the UDF guidelines when posting UDFs. there should be only one UDF per post and the UDF should include a proper header and follow the NoVarsInStrings and Explicit policies.

Also, what value does these UDFs add that other already existing service-related UDFs do not yet provide?
_________________________
There are two types of vessels, submarines and targets.

Top
#139389 - 2005-05-09 05:05 AM Re: stopservices() & startservices()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11629
Loc: CA
Brant

Thank you for you input but please first review the UDF posting Guidelines

Guidelines() - for posting in the UDF forum

I will move this thread to the Scripts forum for now until you've had the time to correct the code.

Thanks for your understanding.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 476 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.053 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org