#75790 - 2003-07-10 09:08 AM
UDF calls
|
didlyjack
Fresh Scripter
Registered: 2003-07-09
Posts: 8
|
First, I know I'm a KiXdiot,
So now here's the question; Must you put a 'call' statement to your UDF library in your script at the begining of every script that uses one (or more) code:
Call library.udf
or will simply stating a function ie: code:
Function scheduletask2() ; insert the function EndFunction
somewhere in your script do the trick? And if so how/where do you save the UDF so that KiXtart will use it? I know that the 'call' works and understand why, but I see a lot of script that doesn't include a 'call' statement to the .UDF and I am confused. Is the 'call' just assumed? Or am I missing something from the "how to's", FAQ's and the manual? Please enlighten. [ 10. July 2003, 09:16: Message edited by: didlyjack ]
|
|
Top
|
|
|
|
#75794 - 2003-07-10 09:33 AM
Re: UDF calls
|
didlyjack
Fresh Scripter
Registered: 2003-07-09
Posts: 8
|
Thanks guys, that totally clears it up. Is that why I always see a 'break on' at the begining of the scripts that don't 'call' the .udf file?
|
|
Top
|
|
|
|
#75795 - 2003-07-10 09:40 AM
Re: UDF calls
|
didlyjack
Fresh Scripter
Registered: 2003-07-09
Posts: 8
|
Lonkero, You said "you only need to call that file(library.udf) once and all the UDFs are included as kixtart function-procedures." Does that include any UDF's in scripts that are called from the first script? [ 10. July 2003, 09:41: Message edited by: didlyjack ]
|
|
Top
|
|
|
|
#75796 - 2003-07-10 09:45 AM
Re: UDF calls
|
didlyjack
Fresh Scripter
Registered: 2003-07-09
Posts: 8
|
HAH, I answered my own question simply by reading what was right in front of me(fancy that). Theanswer to last question is YES!
Thanks a billion boys I totally understand now. (But have no fear I'll be back.)
-J [ 10. July 2003, 09:48: Message edited by: didlyjack ]
|
|
Top
|
|
|
|
#75799 - 2003-07-10 10:01 AM
Re: UDF calls
|
didlyjack
Fresh Scripter
Registered: 2003-07-09
Posts: 8
|
Thanks Lonkero,
I truly appreciate the word "quick" from you about me and my KixTart thinking. Just in case here's my untested script: code:
Call library.udf
; define task $name='demo.job' $name1='demo2.job' $user='administrator' $pw='adminpassword'
; enumerate all computers $domaincomps=comnetview() ; schedule task for each computer For Each $comp In $domaincomps ? 'Scheduling task on '+$comp $rc=scheduletask2($name,$name1,$comp,$user,$pw,) Next ; exit with success code Exit 0
with this as the fnSchedultask2() ( modified from Jens' UDF "Scheduletask()" ) code:
Function scheduletask2($name, name1, $comp, $user, $pw,) Dim $jtexe, $shellcmd, $retcode
If $name='' OR $name1='' OR $comp='' ;date='' OR $time='' OR $type='' Exit 87 EndIf If $user='' OR $pw=''; OR $comment=''OR $command='' Exit 87 EndIf If NOT VarType($parameters) Dim $parameters $parameters='' EndIf
; this should point to your copy of jt.exe $jtexe='jt.exe' If NOT Exist($jtexe) Exit 2 EndIf
; delete a potentially existing task $shellcmd = $jtexe $shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"' $shellcmd = $shellcmd+ ' /SM \\'+$comp $shellcmd = $shellcmd+ ' /SD "'+$name+'"'
Shell '%COMSPEC% /e:1024 /c '+$shellcmd
$shellcmd = $jtexe $shellcmd = $shellcmd+ ' /SVJ '+$name
$shellcmd = $shellcmd+ ' /lJ '+$name1
$shellcmd = $shellcmd+ ' /SC '+$user+' "'+$pw+'"'
$shellcmd = $shellcmd+ ' /SM \\'+$comp Shell '%COMSPEC% /e:1024 /c '+$shellcmd $scheduletask=@ERROR Exit @ERROR EndFunction
[ 10. July 2003, 10:06: Message edited by: didlyjack ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 765 anonymous users online.
|
|
|