Page 2 of 2 <12
Topic Options
#46788 - 2003-10-22 05:10 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You should test code before you post it as others might try to use it.

You should NEVER, EVER use GOTOs! [Mad]

Normally, there is no need to custom-modify UDFs and the ScheduleTask UDF still contains your debugging code.
_________________________
There are two types of vessels, submarines and targets.

Top
#46789 - 2003-10-22 11:57 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Hmm, I think you are right but that is also the reason why I warned the script is not tested.
An other reason why I posted it and I think it is the meaning of this board is that other people can use the idea or parts of this script. Maybe they have some suggestions like you did and I am very thankfull about that so i could make it a better script. When they know this script isn't tested they are going to think about it .. When it was fully tested they maybe use it like an UDF...using it but not knowing how it works...

Please, Let me know if I'm wrong...
_________________________
Co


Top
#46790 - 2003-10-27 01:49 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
This time it is tested and it works fine. (And without Goto's...I guess an old C64 tick... [Big Grin] )

;=============================================================================================== 
;
;Dependencies: UDF's:Scheduletask, Serialtime, netview2, Osid, DateMath, SerialDate, abs.
; Service: Task Scheduler must be installed and running.

; variables Scheduletask function
$name='test'
$date=@DATE
$type='ONCE'
$cmd='notepad'
; variables Serialtime function
$timediff='00:30'
$time='16:30'

; Calling UDF's
;? @scriptdir
Call @Scriptdir+'\netview2.udf'
Call @Scriptdir+'\osid.udf'
;Call @Scriptdir+'\serialtime.udf'
Call @Scriptdir+'\scheduletask.udf'
Call @Scriptdir+'\serialdate.udf'
Call @Scriptdir+'\abs.udf'
Call @Scriptdir+'\datemath.udf'

; Domain scan
$computers=netview2(sasapp)
For Each $computer In $computers

; filter
$os = osid($computer)

If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($computer,"sasn")<>0
$time=serialtime(serialtime($time)+ serialtime($timediff))

; Date
If $time='00:00' OR $TIME='24:00'
$date= DateMath($date, 1)
EndIf

;$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'Found'+ $computer ; test
? 'date'+ $date ;test
EndIf
Next
Exit


;FUNCTION SerialTime (modified -> (HH:MM))
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;SYNTAX SERIALTIME(STRTIME)
;
;EXAMPLE $rc=SERIALTIME('02:20')
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000039
;
Function serialtime($strtime)
Dim $hours, $minutes

If InStr($strtime,':')
$strtime=Split($strtime,':')

Select
Case Ubound($strtime)<1
ReDim preserve $strtime[1]

Case Ubound($strtime)>1
$serialtime=-1
Exit 87
EndSelect

$hours=Val($strtime[0])
If $hours<0 OR $hours>23
$serialtime=-1
Exit 87
EndIf
$minutes=Val($strtime[1])
If $minutes<0 OR $minutes>59
? 'fifteen' +Chr(9)+@ERROR+Chr(9)+$serialtime
$serialtime=-1
Exit 87
EndIf
$serialtime=0.0+($hours*3600)+($minutes*60)
Else
$strtime=Val(CDbl($strtime)*1000)
If $strtime<=86400000 AND $strtime>=0
$hours=$strtime/3600/1000
$strtime=$strtime-($hours*3600*1000)
$hours=Right('00'+$hours,2)
$minutes=$strtime/60/1000
$strtime=$strtime-($minutes*60*1000)
$minutes=Right('00'+$minutes,2)
$serialtime=$hours+':'+$minutes
? 'sixteen' +Chr(9)+@ERROR+Chr(9)+$serialtime
Else
? 'seventeen' +Chr(9)+@ERROR+Chr(9)+$serialtime
$serialtime='-1'
Exit 87
EndIf
EndIf
EndFunction


There is a small problem: After midnight there is a minute missing [Big Grin]

code:
 
FoundServer1
datum2003/10/27
sixteen 0 23:30
FoundServer2
datum2003/10/27
sixteen 0 24:00
FoundServer3
datum2003/10/28
sixteen 0 00:29
FoundServer4
datum2003/10/28
sixteen 0 00:59

Is there a way to check if the Task Scheduler is running on a remote server?

[ 27. October 2003, 14:23: Message edited by: Co ]
_________________________
Co


Top
#46791 - 2003-10-28 03:59 AM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
See the UDF Forum, it contains a couple of UDFs that check whether a service is runing. Also, if the service is not running then the ScheduleTask UDF errors out, thus there's build-in error checking.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 2 of 2 <12


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

Who's Online
0 registered and 194 anonymous users online.
Newest Members
BeeEm, min_seow, Audio, Hoschi, Comet
17882 Registered Users

Generated in 0.061 seconds in which 0.033 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