#110986 - 2004-01-05 11:03 AM
Re: ScheduleTask - Array problem
|
Co
MM club member
 
Registered: 2000-11-20
Posts: 1342
Loc: NL
|
Shane, Jens,
At work it works great. I didn't changed the UDF's since I posted the full script. Next step is to update the ScheduleTask() UDF.
Code:
For Each $comp In $computers
; filter ;------------------------------ ;$os = osid($comp) ; ;If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($comp,"comp")<>0
; Date /Time ;------------------------------ $time=serialtime(serialtime($time)+serialtime($timediff)) $day=Val(Split($time,':')[0]) $hour=Split($time,':')[1] $minute=Split($time,':')[2] $time=$hour+':'+$minute If $time='24:00' $time='00:00' $date=DateMath($date, 1) EndIf If $day>0 $date=DateMath($date, $day) EndIf
; Date Format ;------------ $d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]
; Schedule Task ;------------------------------ ?'' ? 'Task will be scheduled on '+$comp+' on '+$d+' at '+$time $rc=scheduletask($name, $comp, $d, $time, $type, $cmd) ? 'Error '+@ERROR+' - '+@SERROR
Next
There was a small problem at 24:00
Quote:
Task will be scheduled on comp1 on 01/05/2004 at 24:00 Error 1 - Incorrect function.
Task will be scheduled on comp2 on 01/06/2004 at 00:30 Error 0 - The operation completed successfully.
I modified the script with this peace of code: Code:
If $time='24:00' $time='00:00' $date=DateMath($date, 1) EndIf
Problem solved:
Quote:
Task will be scheduled on comp1 on 01/06/2004 at 00:00 Error 0 - The operation completed successfully.
Task will be scheduled on comp2 on 01/06/2004 at 00:30 Error 0 - The operation completed successfully.
Thanks guy's!
_________________________
Co
|
|
Top
|
|
|
|
#110987 - 2004-01-05 12:46 PM
Re: ScheduleTask - Array problem
|
Co
MM club member
 
Registered: 2000-11-20
Posts: 1342
Loc: NL
|
Jens,
I have updated the script with the latest version of ScheduleTask (). It gives an error 87:
Quote:
Task will be scheduled on comp1 on 2004/01/05 at 23:58
Error 87 - The parameter is incorrect.
Task will be scheduled on comp2 on 2004/01/06 at 00:28
Error 87 - The parameter is incorrect.
I have changed $d in $date and remmed out d$:
Code:
For Each $comp In $computers
; filter
;------------------------------
;$os = osid($comp)
;
;If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($comp,"comp")<>0
; Date /Time
;------------------------------
$time=serialtime(serialtime($time)+serialtime($timediff))
$day=Val(Split($time,':')[0])
$hour=Split($time,':')[1]
$minute=Split($time,':')[2]
$time=$hour+':'+$minute
If $time='24:00'
$time='00:00'
$date=DateMath($date, 1)
EndIf
If $day>0
$date=DateMath($date, $day)
EndIf
; Date Format
;------------
;$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]
; Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$date+' at '+$time
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR
Next
Edited by Co (2004-01-05 12:49 PM)
_________________________
Co
|
|
Top
|
|
|
|
#110989 - 2004-01-05 07:43 PM
Re: ScheduleTask - Array problem
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
Maybe...
Code:
If $day>0 $date=DateMath($date, $day) EndIf
Should be...
Code:
If $day>0 $date=DateMath($date, $day) Else $date=@date EndIf
|
|
Top
|
|
|
|
#110990 - 2004-01-06 08:55 AM
Re: ScheduleTask - Array problem
|
Co
MM club member
 
Registered: 2000-11-20
Posts: 1342
Loc: NL
|
Shane,
Sorry, The only code I showed is the FOR NEXT loop because all other parts of the script doesn't changed. I had to let you know...
Jens modified the ScheduleTask(). He added this code to the UDF:
Code:
select
case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case left($date,3)='\'
; valid format
case left($date,5)='\'
; reformat date
$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]
case 1
exit 87
endselect
That's why I remmed out $d(See the full script some topics ago) and changed $d in $date.
Code:
$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]
;Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$d+' at '+$time
$rc=scheduletask($name, $comp, $d, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR
Code:
;$d = Split($date,'/')[1] + '/' + Split($date,'/')[2] + '/' + Split($date,'/')[0]
;Schedule Task
;------------------------------
?''
? 'Task will be scheduled on '+$comp+' on '+$date+' at '+$time
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'Error '+@ERROR+' - '+@SERROR
Edited by Co (2004-01-06 09:15 AM)
_________________________
Co
|
|
Top
|
|
|
|
#110993 - 2004-01-06 05:56 PM
Re: ScheduleTask - Array problem
|
ShaneEP
MM club member
   
Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
|
You're right...The case select portion that Jens added was a little off. The usage of the LEFT function was wrong.
Try Replacing the following...
Code:
select
case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case left($date,3)='\'
; valid format
case left($date,5)='\'
; reformat date
$date=split($date,'\')
$date=$date[1]+'\'+$date[2]+'\'+$date[0]
case 1
exit 87
endselect
With this...
Code:
select
case $date='TODAY'
; valid format
case len($date)<>10
exit 87
case right(left($date,3),1)='/'
; valid format
case right(left($date,5),1)='/'
; reformat date
$date=split($date,'/')
$date=$date[1]+'/'+$date[2]+'/'+$date[0]
case 1
exit 87
endselect
|
|
Top
|
|
|
|
#110998 - 2004-01-07 10:44 AM
Re: ScheduleTask - Array problem
|
Co
MM club member
 
Registered: 2000-11-20
Posts: 1342
Loc: NL
|
|
|
Top
|
|
|
|
#111000 - 2004-01-07 07:14 PM
Re: ScheduleTask - Array problem
|
Co
MM club member
 
Registered: 2000-11-20
Posts: 1342
Loc: NL
|
Jens,
I didn't tested it but I think you have to replace the backslashes with slashes since the date format must be MM/DD/YYYY... Code:
case substr($date,3,1)='\' ; valid format case substr($date,5,1)='\' ; reformat date $date=split($date,'\') $date=$date[1]+'\'+$date[2]+'\'+$date[0]
Must be...
Code:
case substr($date,3,1)='/' ; valid format case substr($date,5,1)='/' ; reformat date $date=split($date,'/') $date=$date[1]+'/'+$date[2]+'/'+$date[0]
Feeding the baby again.. or did you had a very short and broken night
_________________________
Co
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 837 anonymous users online.
|
|
|