Page 1 of 2 12>
Topic Options
#46768 - 2003-10-16 12:22 AM How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Any idea how i can use Scheduletask() for 35 servers?

In the past i used a script like:

At \\server1 17:15 scopy /o /a /s \\distrisrv1\cdfoon d:\cdfoon

At \\server2 17:45 scopy /o /a /s \\distrisrv1\cdfoon d:\cdfoon

At \\server3 18:15 scopy /o /a /s \\distrisrv1\cdfoon d:\cdfoon

etc.

I want to use the Scheduletask() UDF the same way

With this script I can schedule only one task:
code:
$name='test' 
$comp='sasntest'
$date='TODAY'
$time='now'
$type='ONCE'
$cmd='notepad'
$user='admin'
$pw='adminpw'
;$comment='test'
;$jt= 'c:\jt.exe'
?@ERROR
scheduletask($name, $comp, $date, $time, $type, $cmd, $user, $pw)
?@ERROR
? @SERROR


:END
Sleep 30
Exit

;FUNCTION ScheduleTask
;
;ACTION Schedules a task on any computer using the Task Scheduler
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000060
;
Function scheduletask($name, $comp, $date, $time, $type, $cmd, optional $prms, optional $user, optional $pw, optional $comment, optional $typeargs, optional $jt)
Dim $jtexe[3], $shellcmd, $path

If $name='' OR $comp='' OR $date='' OR $time='' OR $type='' OR $cmd=''
? @ERROR
Exit 87
EndIf

; create an array of potential filepaths to jt.exe
$jtexe[0]=$jt
$jtexe[1]='c:\jt.exe'
$jtexe[2]=@SCRIPTDIR+'\jt.exe'
$jtexe[3]=@CURDIR+'\jt.exe'
$path=Split('%PATH%',';')
For Each $jt In $path
ReDim preserve $jtexe[Ubound($jtexe)+1]
$jtexe[Ubound($jtexe)]=Join(Split($jt+'\jt.exe','\\'),'\')
Next

; check each filepath for the presence of jt.exe
For Each $jt In $jtexe
If Exist($jt) AND NOT (GetFileAttr($jt) & 16) AND Ubound($jtexe)+1
$jtexe=$jt
EndIf
Next
Select
Case Ubound($jtexe)+1
Exit 2
Case NOT Exist($jtexe)
Exit 2
EndSelect

If Left($comp,2)<>'\\'
$comp='\\'+$comp
EndIf

If Right($name,4)<>'.job'
$name=$name+'.job'
EndIf

; delete a potentially existing task
$shellcmd = $jtexe
If $user AND $pw
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
EndIf
$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SD "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'

$shellcmd = $jtexe

If $user AND $pw
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
EndIf

$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$cmd+'"'

If $prms
$shellcmd = $shellcmd+ ' Parameters="'+$prms+'"'
EndIf

$shellcmd = $shellcmd+ ' WorkingDirectory="%SYSTEMROOT%"'
$shellcmd = $shellcmd+ ' Comment="'+$comment+'"'
$shellcmd = $shellcmd+ ' Creator="'+@userid+'"'
$shellcmd = $shellcmd+ ' Priority=Normal'
$shellcmd = $shellcmd+ ' MaxRunTime=3600000'
$shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0'
$shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0'
$shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0'
$shellcmd = $shellcmd+ ' SystemRequired=0'
$shellcmd = $shellcmd+ ' DeleteWhenDone=1'
$shellcmd = $shellcmd+ ' Suspend=0'
$shellcmd = $shellcmd+ ' StartOnlyIfIdle=0'
$shellcmd = $shellcmd+ ' KillOnIdleEnd=0'
$shellcmd = $shellcmd+ ' RestartOnIdleResume=0'
$shellcmd = $shellcmd+ ' Hidden=0'
$shellcmd = $shellcmd+ ' TaskFlags=0'

$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date
$shellcmd = $shellcmd+ ' StartTime='+$time
$shellcmd = $shellcmd+ ' HasEndDate=0'
$shellcmd = $shellcmd+ ' KillAtDuration=0'
$shellcmd = $shellcmd+ ' Disabled=0'
$shellcmd = $shellcmd+ ' Type='+$type
If $typeargs
$shellcmd = $shellcmd+ ' TypeArguments='+$typeargs
EndIf

$shellcmd = $shellcmd+ ' /SAJ "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'
$scheduletask=@ERROR
? @ERROR
Exit @ERROR
EndFunction



[ 15. October 2003, 13:01: Message edited by: Co ]
_________________________
Co


Top
#46769 - 2003-10-15 02:32 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Of course i can use something like:

jt /sc "domain\admin" "adminpw" /sm \\server1 /sj applicationname="xcopy" Parameters="\\distrisrv1\cdfoon d:\cdfoon /E /V /C /I /Q /G /H /R /K /O /X /Y /Z" /ctj startdate=today StartTime=17:00 type=once /saj "testje"

jt /sc "domain\admin" "adminpw" /sm \\server2 /sj applicationname="xcopy" Parameters="\\distrisrv1\cdfoon d:\cdfoon /E /V /C /I /Q /G /H /R /K /O /X /Y /Z" /ctj startdate=today StartTime=17:30 type=once /saj "testje"

jt /sc "domain\admin" "adminpw" /sm \\server3 /sj applicationname="xcopy" Parameters="\\distrisrv1\cdfoon d:\cdfoon /E /V /C /I /Q /G /H /R /K /O /X /Y /Z" /ctj startdate=today StartTime=18:00 type=once /saj "testje"

etc.

[ 15. October 2003, 15:03: Message edited by: Co ]
_________________________
Co


Top
#46770 - 2003-10-16 04:46 AM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Just put the list of servers into an array.
code:
$servers='server1','server2','server3'
for each $server in $servers
$rc=scheduletask($server,...)
next

_________________________
There are two types of vessels, submarines and targets.

Top
#46771 - 2003-10-16 07:09 AM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
I have thought about it but.... and do the same with the start time?
_________________________
Co


Top
#46772 - 2003-10-16 06:56 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Just use any of the date math UDFs for that.
code:
$servers='server1','server2','server3'
$timediff='00:30:00'
$starttime='17:00:00'
for each $server in $servers
$starttime=serialtime(serialtime($starttime)+serialtime($timediff)))
$rc=scheduletask($server,...)
next



[ 17. October 2003, 20:09: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#46773 - 2003-10-16 08:25 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Thanks. [Wink] I will use this. I've tried something with for each next for each but that didn't work. I'll let you know the result..

Ps. Congratiolations with the German Ladies soccer team!!

[ 16. October 2003, 20:30: Message edited by: Co ]
_________________________
Co


Top
#46774 - 2003-10-17 08:06 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Hmmmmm,

Sealeopard,

When I read your Reply I had the idea that it must be very simple to finish the script. But it wasn't. I've used your serialtime UDF and the one from Scriptlogic but both give errors [Frown] . I used the code from your post, corrected the typo and modified it until it fits into the script.

After the error 1 I placed an ? @error between almost every if and endif. It looks that the first run is OK but after that an error occurs. I left the script at work and I'm not the mood [Mad] to pick it up this weekend. So monday I post the script....

[ 17. October 2003, 20:11: Message edited by: Co ]
_________________________
Co


Top
#46775 - 2003-10-21 12:14 AM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
New Week, new start...

I modified the serialtime UDF so it uses only hours and minutes. And it works fine.. No more errors..BUT the tasks aren't scheduled!! [Frown]

code:
  
; variabelen Scheduletask function
$name='test'
$date='TODAY'
$type='ONCE'
$cmd='notepad'

; variabelen Serialtime function
$timediff='00:30'
$time='16:30'
$comps='server1','server2'
? 'one'+Chr(9)+@error; + $comps

For Each $comp In $comps
$time=serialtime(serialtime($time)+ serialtime($timediff))
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
? 'two' +Chr(9)+@error+Chr(9)+$name+Chr(9)+$comp+Chr(9)+$date+Chr(9)+$time+Chr(9)+$type+Chr(9)+$cmd

next
:END
Sleep 30
Exit

;FUNCTION ScheduleTask
;
;ACTION Schedules a task on any computer using the Task Scheduler
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;VERSION 1.3 (made username/password/comment optional parameters, changed parameter order, added
; optional parameter for JT.EXE location, checks %PATH% for presence of JT.EXE)
;
;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000060
;
Function scheduletask($name, $comp, $date, $time, $type, $cmd, optional $prms, optional $user, optional $pw, optional $comment, optional $typeargs, optional $jt)
Dim $jtexe[5], $shellcmd, $path
$jtpathL='c:\scripts\tools'
$jtpathS='\\server1\scripts\tools'
If $name='' OR $comp='' OR $date='' OR $time='' OR $type='' OR $cmd=''
? 'three' +Chr(9)+@ERROR
Exit 87
EndIf

; create an array of potential filepaths to jt.exe
$jtexe[0]=$jt
$jtexe[1]=$jtpathL+'\jt.exe'
$jtexe[2]=@SCRIPTDIR+'\jt.exe'
$jtexe[3]=@CURDIR+'\jt.exe'
$jtexe[4]=@STARTDIR+'\jt.exe'
$jtexe[5]=$jtpathS+'\jt.exe'
$path=Split('%PATH%',';')
For Each $jt In $path
ReDim preserve $jtexe[Ubound($jtexe)+1]
$jtexe[Ubound($jtexe)]=Join(Split($jt+'\jt.exe','\\'),'\')
? 'four' +Chr(9)+@ERROR
Next

? 'five' +Chr(9)+@ERROR
; check each filepath for the presence of jt.exe
For Each $jt In $jtexe
If Exist($jt) AND NOT (GetFileAttr($jt) & 16) AND Ubound($jtexe)+1
$jtexe=$jt
? 'six' +Chr(9)+@ERROR
EndIf
Next
Select
Case Ubound($jtexe)+1
Exit 2
Case NOT Exist($jtexe)
Exit 2
? 'seven' +Chr(9)+@ERROR
EndSelect

If Left($comp,2)<>'\\'
$comp='\\'+$comp
? 'eight' +Chr(9)+@ERROR
EndIf

If Right($name,4)<>'.job'
$name=$name+'.job'
? 'nine' +Chr(9)+@ERROR
EndIf

; delete a potentially existing task
$shellcmd = $jtexe
If $user AND $pw
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
? 'ten' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SD "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'

$shellcmd = $jtexe

If $user AND $pw
? 'eleven' +Chr(9)+@ERROR
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
EndIf

$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$cmd+'"'

If $prms
$shellcmd = $shellcmd+ ' Parameters="'+$prms+'"'
? 'twelve' +Chr(9)+@ERROR
EndIf

$shellcmd = $shellcmd+ ' WorkingDirectory="%SYSTEMROOT%"'
$shellcmd = $shellcmd+ ' Comment="'+$comment+'"'
$shellcmd = $shellcmd+ ' Creator="'+@userid+'"'
$shellcmd = $shellcmd+ ' Priority=Normal'
$shellcmd = $shellcmd+ ' MaxRunTime=3600000'
$shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0'
$shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0'
$shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0'
$shellcmd = $shellcmd+ ' SystemRequired=0'
$shellcmd = $shellcmd+ ' DeleteWhenDone=1'
$shellcmd = $shellcmd+ ' Suspend=0'
$shellcmd = $shellcmd+ ' StartOnlyIfIdle=0'
$shellcmd = $shellcmd+ ' KillOnIdleEnd=0'
$shellcmd = $shellcmd+ ' RestartOnIdleResume=0'
$shellcmd = $shellcmd+ ' Hidden=0'
$shellcmd = $shellcmd+ ' TaskFlags=0'

$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date
$shellcmd = $shellcmd+ ' StartTime='+$time
$shellcmd = $shellcmd+ ' HasEndDate=0'
$shellcmd = $shellcmd+ ' KillAtDuration=0'
$shellcmd = $shellcmd+ ' Disabled=0'
$shellcmd = $shellcmd+ ' Type='+$type
If $typeargs
$shellcmd = $shellcmd+ ' TypeArguments='+$typeargs
? 'thirteen' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SAJ "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'
$scheduletask=@ERROR
? 'fourteen' +Chr(9)+@ERROR
Exit @ERROR
EndFunction


;FUNCTION SerialTime
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;ACTION Convert time to numbers (and back) for the purpose of performing time math
;
;VERSION 1.1
;
;KIXTART 4.20
;
;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

code:
@error output:

one 0
sixteen 0 17:00
four 0
four 0
four 0
four 0
four 0
four 0
four 0
five 0
six 0
eight 0
nine 0
fourteen 0
two 0 test server1 TODAY 17:00 ONCE notepad
sixteen 0 17:30
four 0
four 0
four 0
four 0
four 0
four 0
four 0
five 0
six 0
eight 0
nine 0
fourteen 0
two 0 test server2 TODAY 17:30 ONCE notepad

_________________________
Co


Top
#46776 - 2003-10-20 02:06 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
I think i know why it did not work: [Frown]
quote:
.....Fortunately, all our computers are running at least Microsoft Internet Explorer 5. IE 5.x+ comes with a component ('offline synchronization') that replaces the scheduler service with the 'Task Scheduler'. The task scheduler runs under the SYSTEM account which cannot be changed. The advantage of the task scheduler over the scheduler service is that the task scheduler allows to run scheduled commands under arbitrary user accounts.....
- Sealeopard -

Unfortunately the Task Scheduler service does not exist on all our servers. And of course I tested the ones who don't have it [Mad] [Mad] .....

[ 20. October 2003, 14:15: Message edited by: Co ]
_________________________
Co


Top
#46777 - 2003-10-20 03:22 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Yes, that would do it. However, Windows 2000/XP/2003 have the Task Scheduler by default, the only OS requiring the installation of the Task scheduler component is Windows NT. I'll add the presence of the 'Task Scheduler' service as a dependency.
_________________________
There are two types of vessels, submarines and targets.

Top
#46778 - 2003-10-20 04:00 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Hmmm, Strange one of the servers is W2K as you can see...

quote:

System summary:
OS Name Microsoft Windows 2000 Advanced Server
Version 5.0.2195 Service Pack 3 Build 2195

OS Manufacturer Microsoft Corporation

System Name SERVER1

System Manufacturer Not Available
System Model Not Available

System Type X86-based PC

Internet Explorer File version:
iesetup.dll 6.0.2600.0 57 KB 17-8-2001 22:43...

iexplore.exe 6.0.2600.0 89 KB 17-8-2001 22:43...

Services:
.....
Terminal Services TermService Runni... Auto
Telnet TlntSvr Stopp... Manual

Telephony TapiSrv Stopp... Manual

TCP/IP NetBIOS Helper Se... LmHosts Runni... Auto

System Event Notification SENS Runni... Auto
Surveyor Surveyor Runni... Auto
.....

_________________________
Co


Top
#46779 - 2003-10-20 04:16 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Then somebody has purposefully removed the 'Task Scheduler' service as it is part of a default installation.
_________________________
There are two types of vessels, submarines and targets.

Top
#46780 - 2003-10-20 04:29 PM Re: How to use Scheduletask () for multiple tasks/servers?
Everyone Offline
Getting the hang of it

Registered: 2003-10-19
Posts: 81
Loc: Beale Air Force Base, CA
Instead of building a whole list of 35? servers, why not try something like.

$Server = INSTR(@ProductType,"Server")

That is assuming all your servers are running a server O/S.

If for some reason that is not the case... maybe your servers have a standard naming convention?

Maybe something like:

$Server = INSTR(@WKSTA,"SRV-")

Probably won't fix your problem with the tasks not scheduling, but make creating a huge server list a lot easier.

Top
#46781 - 2003-10-20 04:52 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Everybody **LOL** ... Sometimes I use Yourself when I play UT..You know ..You are killed by..

Good idea.. I think I use it to modify this script. About the task scheduler... I Work for a Dutch IT company. This means that I have to work for different orginisations/clients. At this moment I work for a companie that isn't very organised... [Big Grin] . (Thinks like: you can't reboot this server because we do not know if it starts again [Wink] ) But they use ITIL, So they say everything is OK...NOT

[ 20. October 2003, 20:44: Message edited by: Co ]
_________________________
Co


Top
#46782 - 2003-10-20 04:58 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
You could also use the OSID() UDF in combination with the NetView2()UDF to identify servers remotely.
_________________________
There are two types of vessels, submarines and targets.

Top
#46783 - 2003-10-20 08:38 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Hmmm, busy day tommorow... [Big Grin]
_________________________
Co


Top
#46784 - 2003-10-21 04:18 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Thanks! [Smile] I have used it all! [Big Grin]
I think I have to say this is Sealeopard's script and a bit of mine.
(Or can I use more of his UDF's in one script.. [Big Grin] )

; variabelen voor Scheduletask function  
$name='test'
$date='TODAY'
$type='ONCE'
$cmd='notepad'
; variabelen voor Serialtime function
$timediff='00:30'
$time='16:30'

;Call @Scriptdir+'\netview2.udf'
$computers=netview2(Domain)
For Each $computer In $computers
;Call @Scriptdir+'\osid.udf'
$os = osid($computer)
If $os[1]='Win2K' and $os[2]<>'Workstation' and InStr($computer,"server")<>0
;Call @Scriptdir+'\serialtime.udf'
;$time=serialtime(serialtime($time)+ serialtime($timediff))
;Call @Scriptdir+'\scheduletask.udf'
;$rc=scheduletask($name, $computer, $date, $time, $type, $cmd)
? 'gevonden'+ $computer
EndIf
Next
:END
Sleep 30
Exit

;FUNCTION ScheduleTask
;
;AUTHOR Jens Meyer (sealeopard@usa.net)

;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000060
;
Function scheduletask($name, $comp, $date, $time, $type, $cmd, optional $prms, optional $user, optional $pw, optional $comment, optional $typeargs, optional $jt)
Dim $jtexe[5], $shellcmd, $path
$jtpathL='c:\scripts\tools'
$jtpathS='\\server1\scripts\tools'
If $name='' OR $comp='' OR $date='' OR $time='' OR $type='' OR $cmd=''
? 'three' +Chr(9)+@ERROR
Exit 87
EndIf

; create an array of potential filepaths to jt.exe
$jtexe[0]=$jt
$jtexe[1]=$jtpathL+'\jt.exe'
$jtexe[2]=@SCRIPTDIR+'\jt.exe'
$jtexe[3]=@CURDIR+'\jt.exe'
$jtexe[4]=@STARTDIR+'\jt.exe'
$jtexe[5]=$jtpathS+'\jt.exe'
$path=Split('%PATH%',';')
For Each $jt In $path
ReDim preserve $jtexe[Ubound($jtexe)+1]
$jtexe[Ubound($jtexe)]=Join(Split($jt+'\jt.exe','\\'),'\')
? 'four' +Chr(9)+@ERROR
Next

? 'five' +Chr(9)+@ERROR
; check each filepath for the presence of jt.exe
For Each $jt In $jtexe
If Exist($jt) AND NOT (GetFileAttr($jt) & 16) AND Ubound($jtexe)+1
$jtexe=$jt
? 'six' +Chr(9)+@ERROR
EndIf
Next
Select
Case Ubound($jtexe)+1
Exit 2
Case NOT Exist($jtexe)
Exit 2
? 'seven' +Chr(9)+@ERROR
EndSelect

If Left($comp,2)<>'\\'
$comp='\\'+$comp
? 'eight' +Chr(9)+@ERROR
EndIf

If Right($name,4)<>'.job'
$name=$name+'.job'
? 'nine' +Chr(9)+@ERROR
EndIf

; delete a potentially existing task
$shellcmd = $jtexe
If $user AND $pw
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
? 'ten' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SD "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'

$shellcmd = $jtexe

If $user AND $pw
? 'eleven' +Chr(9)+@ERROR
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
EndIf

$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$cmd+'"'

If $prms
$shellcmd = $shellcmd+ ' Parameters="'+$prms+'"'
? 'twelve' +Chr(9)+@ERROR
EndIf

$shellcmd = $shellcmd+ ' WorkingDirectory="%SYSTEMROOT%"'
$shellcmd = $shellcmd+ ' Comment="'+$comment+'"'
$shellcmd = $shellcmd+ ' Creator="'+@userid+'"'
$shellcmd = $shellcmd+ ' Priority=Normal'
$shellcmd = $shellcmd+ ' MaxRunTime=3600000'
$shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0'
$shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0'
$shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0'
$shellcmd = $shellcmd+ ' SystemRequired=0'
$shellcmd = $shellcmd+ ' DeleteWhenDone=1'
$shellcmd = $shellcmd+ ' Suspend=0'
$shellcmd = $shellcmd+ ' StartOnlyIfIdle=0'
$shellcmd = $shellcmd+ ' KillOnIdleEnd=0'
$shellcmd = $shellcmd+ ' RestartOnIdleResume=0'
$shellcmd = $shellcmd+ ' Hidden=0'
$shellcmd = $shellcmd+ ' TaskFlags=0'

$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date
$shellcmd = $shellcmd+ ' StartTime='+$time
$shellcmd = $shellcmd+ ' HasEndDate=0'
$shellcmd = $shellcmd+ ' KillAtDuration=0'
$shellcmd = $shellcmd+ ' Disabled=0'
$shellcmd = $shellcmd+ ' Type='+$type
If $typeargs
$shellcmd = $shellcmd+ ' TypeArguments='+$typeargs
? 'thirteen' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SAJ "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'
$scheduletask=@ERROR
? 'fourteen' +Chr(9)+@ERROR
Exit @ERROR
EndFunction


;FUNCTION SerialTime
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;SYNTAX SERIALTIME(STRTIME)
;
;EXAMPLE $rc=SERIALTIME('02:20:33.187')
;
;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

;FUNCTION OSID
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;EXAMPLE $currentos = osid()
; $installdate = CTime($currentos[9])
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000019
;
Function osid(optional $sComp)
Dim $osidarray[11]

Dim $iINWIN, $sDOS, $iBUILD, $sCSD, $iPRODUCTSUITE, $sPRODUCTTYPE


Dim $operating_system, $sp_level, $os_suite, $os_short, $productsuite
Dim $os_type, $os_role, $os_flavor, $os_subver, $regkey
Dim $os_build, $os_proc, $os_owner, $os_org, $os_key, $os_date, $os_oem
Dim $os_lang

$sComp=Trim($sComp)
Select
Case $sComp=@WKSTA
$sComp=''
Case $sComp AND NOT KeyExist('\\'+$sComp+'\HKLM')
Exit 2
Case $sComp
$sComp='\\'+$sComp+'\'
EndSelect

; fetch all macro info depending on whether it's remote or local
If $sComp
If KeyExist($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList')
$iINWIN=1
$sDOS=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CurrentVersion')
$iBUILD=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CurrentBuildNumber')
$sCSD=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CSDVersion')
If $sDOS='4.0' AND ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009','Installed')
$sCSD=$sCSD+'a'
EndIf
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions','ProductType')
Select
Case $sPRODUCTTYPE='WinNT'
If $sDOS='4.0'
$sPRODUCTTYPE='Workstation'
Else
$sPRODUCTTYPE='Professional'
EndIf
Case $sPRODUCTTYPE='ServerNT'
If $sDOS='5.2'
$sPRODUCTTYPE=''
Else
$sPRODUCTTYPE='Server'
EndIf
Case $sPRODUCTTYPE='LANManNT'
$sPRODUCTTYPE='Domain Controller'
Case 1
$sPRODUCTTYPE='Home Edition'
EndSelect
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','ProductName')+' '+$sPRODUCTTYPE
$sPRODUCTTYPE=Join(Split($sPRODUCTTYPE,'Microsoft'),'')
$iPRODUCTSUITE=''
$os_lang=$sComp+Join(Split(ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','SystemRoot'),':\'),'$\')+'\system32\shell32.dll'
$os_lang=GetFileVersion($os_lang,'Language')
Else
$iINWIN=2
$dDOS=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','VersionNumber')
$dDOS=Split($dDOS,'.')
$iBUILD=$dDOS[Ubound($dDOS)]
ReDim preserve $dDOS[1]
$sDOS=Join($dDOS,'.')
$sCSD=''
$iPRODUCTSUITE=''
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','Version')
$os_lang=Right(''+ReadValue($sComp+'HKLM\SYSTEM\CurrentControlSet\Control\Nls\Locale',''),4)
EndIf
Else
$iINWIN=@INWIN
$sDOS=@DOS
$iBUILD=@BUILD
$sCSD=@CSD
$iPRODUCTSUITE=@PRODUCTSUITE
$sPRODUCTTYPE=@PRODUCTTYPE
$os_lang=@SYSLANG
EndIf

; set the correct registry key
If $iINWIN=1
$regkey='HKLM\Software\Microsoft\Windows NT\CurrentVersion'
Else
$regkey='HKLM\Software\Microsoft\Windows\CurrentVersion'
EndIf
If $sComp
$regkey=$sComp+$regkey
EndIf

; retrieve registered owner, organization, build, type
$os_owner=ReadValue($regkey,'RegisteredOwner')
$os_org=ReadValue($regkey,'RegisteredOrganization')
$os_proc=ReadValue($regkey,'CurrentType')
$os_build=Val($iBUILD)

Select
Case $iINWIN=1
; determine the operating system kernel
Select
Case $sDOS='6.0'
$operating_system='Windows Longhorn'
Select
Case $os_build=4015
$operating_system=$operating_system+' (Alpha Preview 3)'
Case $os_build=4008
$operating_system=$operating_system+' (Alpha Preview 2)'
Case 1
$operating_system=$operating_system+' (Alpha/Beta/RC)'
EndSelect
$os_short='WinLonghorn'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='5.2'
$operating_system='Windows Server 2003'
$os_short='Win2K3'
$os_key=ReadValue($regkey,'ProductID')
Select
Case $os_build=3714
$operating_system=$operating_system+' (RC1)'
Case $os_build<3790
$operating_system=$operating_system+' (Alpha/Beta/RC)'
EndSelect
Case $sDOS='5.1'
$operating_system='Windows XP'
Select
Case $os_build=2250
$operating_system=$operating_system+' (Alpha)'
Case $os_build=2257
$operating_system=$operating_system+' (Alpha)'
Case $os_build=2410
$operating_system=$operating_system+' (Beta 1)'
Case $os_build=2416
$operating_system=$operating_system+' (Beta 1)'
Case $os_build=2462
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2465
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2496
$operating_system=$operating_system+' (RC1)'
Case $os_build=2505
$operating_system=$operating_system+' (RC1)'
Case $os_build=2526
$operating_system=$operating_system+' (RC2)'
Case $os_build=2542
$operating_system=$operating_system+' (RC3)'
EndSelect
$os_short='WinXP'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='5.0'
$operating_system='Windows 2000'
Select
Case $os_build=1515
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2031
$operating_system=$operating_system+' (Beta 3)'
Case $os_build=2128
$operating_system=$operating_system+' (Beta 3 RC2)'
Case $os_build=2183
$operating_system=$operating_system+' (Beta 3)'
EndSelect
$os_short='Win2k'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='4.0'
$operating_system='Windows NT 4.0'
$os_short='WinNT'
$os_key=ReadValue($regkey,'ProductID')
$os_key=Left($os_key,5)+'-'+SubStr($os_key,6,3)+'-'+SubStr($os_key,10,7)+'-'+Right($os_key,5)
Case 1
$operating_system='unknown'
$os_short='unknown'
EndSelect

; determine the service pack level
$sp_level=$sCSD
If InStr($sp_level,'Service Pack')
$sp_level=Split($sp_level,'Service Pack')
$sp_level=Trim($sp_level[Ubound($sp_level)])
Else
$sp_level=0
EndIf

; determine the product suite
$productsuite=Val($iPRODUCTSUITE)
$os_suite=''
If $productsuite
If $productsuite & 1
$os_suite=$os_suite+'Small Business |'
EndIf
If $productsuite & 2
$os_suite=$os_suite+'Enterprise |'
EndIf
If $productsuite & 4
$os_suite=$os_suite+'BackOffice |'
EndIf
If $productsuite & 8
$os_suite=$os_suite+'Communication Server |'
EndIf
If $productsuite & 16
$os_suite=$os_suite+'Terminal Server |'
EndIf
If $productsuite & 32
$os_suite=$os_suite+'Small Business (Restricted) |'
EndIf
If $productsuite & 64
$os_suite=$os_suite+'Embedded NT |'
EndIf
If $productsuite & 128
$os_suite=$os_suite+'DataCenter |'
EndIf
If $productsuite & 256
$os_suite=$os_suite+'Single User Terminal Server |'
EndIf
If $productsuite & 512
$os_suite=$os_suite+'Home Edition |'
EndIf
If $productsuite & 1024
$os_suite=$os_suite+'Blade Server |'
EndIf
If InStr($os_suite,'|')
$os_suite=Left($os_suite,Len($os_suite)-2)
EndIf
EndIf

; determine the producy type
$os_type=$sPRODUCTTYPE
Select
Case InStr($os_type,'Domain Controller')
$os_role='Domain Controller'
$os_flavor='Server'
Case InStr($os_type,'Server')
$os_role='Member Server'
$os_flavor='Server'
Case InStr($os_type,'Workstation')
$os_role='Workstation'
$os_flavor='Workstation'
Case InStr($os_type,'Professional')
$os_role='Workstation'
$os_flavor='Workstation'
Case InStr($os_type,'Tablet PC')
$os_role='Workstation'
$os_flavor='Tablet PC'
Case InStr($os_type,'Home Edition')
$os_role='Workstation'
$os_flavor='Workstation'
Case 1
$os_role='unknown'
$os_flavor='unknown'
EndSelect

$operating_system=$operating_system+' '+$os_flavor+' Service Pack '+$sp_level
If $os_suite<>''
$operating_system=$operating_system+' ['+$os_suite+']'
EndIf

; determine the installation date
$os_date=ReadValue('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','Installdate')

; determine the OEM Duplicator String
$os_oem=ReadValue('HKLM\System\Setup','OemDuplicatorString')

Case $iINWIN=2
$os_short='Win9x'
$os_role='Workstation'
$sp_level=0

$os_subver=Lcase(ReadValue($regkey,'SubVersionNumber'))

Select
Case $sDOS='4.90'
$operating_system='Windows ME'
$os_key=ReadValue($regkey,'ProductKey')
$os_flavor=''
Case $sDOS='4.10'
$operating_system='Windows 98'
$os_key=ReadValue($regkey,'ProductKey')
Select
Case InStr($os_subver,'c')
$os_flavor='SE'
Case InStr($os_subver,'b')
$os_flavor='B'
Case $os_subver=' a '
$os_flavor='Second Edition'
Case 1
$os_flavor='OEM'
EndSelect
Case $sDOS='4.0'
$operating_system='Windows 95'
$os_key=ReadValue($regkey,'ProductID')
Select
Case InStr($os_subver,'c')
$os_flavor='OSR 2.5'
Case InStr($os_subver,'b')
$os_flavor='OSR 2.0'
Case InStr($os_subver,'a')
$os_flavor=' Service Pack 1'
Case 1
$os_flavor=' OEM'
EndSelect
Case 1
$operating_system='unknown'
$os_short='unknown'
EndSelect

If $os_flavor
$operating_system=$operating_system+' '+$os_flavor
EndIf

EndSelect

$osidarray[0]=$operating_system
$osidarray[1]=$os_short
$osidarray[2]=$os_role
$osidarray[3]=$sp_level
$osidarray[4]=$os_build
$osidarray[5]=$os_proc
$osidarray[6]=$os_owner
$osidarray[7]=$os_org
$osidarray[8]=$os_key
$osidarray[9]=$os_date
$osidarray[10]=$os_oem
$osidarray[11]=$os_lang

$osid=$osidarray

EndFunction

;FUNCTION NetView2()
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;CONTRIBUTOR Shawn Tassie
;
;SYNTAX NetView2([Domain,Comment])
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000202
;
Function NetView2(optional $domain, optional $commentflag)
Dim $array[255]
Dim $ReDim, $i, $j, $tempfile
Dim $filehandle, $retcode, $line
Dim $name, $comment

$ReDim = 255
$i = 0
$j = 0
$tempfile = '%temp%\netview.tmp'

If $domain
$domain = '/domain:'+Trim($domain)
EndIf

If VarType($commentflag)
$commentflag=Val($commentflag)
Else
$commentflag=0
EndIf

If Exist($tempfile)
Del $tempfile
EndIf

Shell '%comspec% /c net view '+$domain+' >"'+$tempfile+'"'

If @error = 0
$filehandle=FreeFileHandle()
$retcode=Open($filehandle,$tempfile)

For $j = 1 to 5
$line = ReadLine($filehandle) ; skip headings
Next

While @error = 0
$name= Trim(SubStr($line,3,InStr($line,' ')-1))
$comment = Trim(Right($line,Len($line)-InStr($line,' ')))
If $commentflag
$array[$i]=$name+','+$comment
Else
$array[$i]=$name
EndIf
$i=$i+1
If $i = $ReDim
$ReDim=$ReDim*2
ReDim preserve $array[$ReDim]
EndIf
$line = ReadLine($filehandle)
Loop
_________________________
Co


Top
#46785 - 2003-10-21 05:38 PM Re: How to use Scheduletask () for multiple tasks/servers?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11162
Loc: Boston, MA, USA
Double-check the time math. SERIALTIME does not perform next-day rollovers. Thus, if you have too many servers to schedule, you will end up with 23:30, 00:00, 00:30 for the same day instead of having 00:00 and 00:30 roll over to the next day.

[ 21. October 2003, 17:39: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#46786 - 2003-10-21 08:50 PM Re: How to use Scheduletask () for multiple tasks/servers?
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1338
Loc: NL
Thanks,
I will check that..
_________________________
Co


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

Registered: 2000-11-20
Posts: 1338
Loc: NL
I have modified it again... There are now 7 udf's included. Next time I only post my own part [Big Grin] and udf's that i have modified.
I didn't tested it so maybe it is full of error's...

;=============================================================================================== 
;**** Created By Co ****
;**** Last Modified on 22-10-2003 at 16:59:56 by Co ****
;**** Not tested jet ****
;===============================================================================================
;
;Dependencies: UDF's:Scheduletask, Serialtime, netview2, DateMath, SerialDate, abs, ActiveService.
;

$log='d:\log\schedule.txt'
; variables Scheduletask function
$name='test'
$date=@DATE
$type='ONCE'
$cmd='notepad'
; variables Serialtime function
$timediff='00:30'
$time='16:30'

;Call @Scriptdir+'\netview2.udf'
$computers=netview2(sasapp)
For Each $computer In $computers
;Call @Scriptdir+'\osid.udf'
$os = osid($computer)
If $os[1]='Win2K' AND $os[2]<>'Workstation' AND InStr($computer,"sasn")<>0
;Call @Scriptdir+'\serialtime.udf'
$time=serialtime(serialtime($time)+ serialtime($timediff))
If $time='00:00'
$date= DateMath($date,1)
EndIf
If ACTIVESERVICE("Task Scheduler")<>1
GoTo log
EndIf
;Call @Scriptdir+'\scheduletask.udf'
$rc=scheduletask($name, $comp, $date, $time, $type, $cmd)
;? 'Found'+ $computer
EndIf
Next
:log
If Open(1,$log,5) = 0
WriteLine(1,"Task Scheduler Service isn't installed on"+ $computer)
$nul=Close(1)
Endif
:END
Exit

;FUNCTION ScheduleTask
;
;AUTHOR Jens Meyer (sealeopard@usa.net)

;KIXTART BBS http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000060
;
Function scheduletask($name, $comp, $date, $time, $type, $cmd, optional $prms, optional $user, optional $pw, optional $comment, optional $typeargs, optional $jt)
Dim $jtexe[5], $shellcmd, $path
$jtpathL='c:\scripts\tools'
$jtpathS='\\server1\scripts\tools'
If $name='' OR $comp='' OR $date='' OR $time='' OR $type='' OR $cmd=''
? 'three' +Chr(9)+@ERROR
Exit 87
EndIf

; create an array of potential filepaths to jt.exe
$jtexe[0]=$jt
$jtexe[1]=$jtpathL+'\jt.exe'
$jtexe[2]=@SCRIPTDIR+'\jt.exe'
$jtexe[3]=@CURDIR+'\jt.exe'
$jtexe[4]=@STARTDIR+'\jt.exe'
$jtexe[5]=$jtpathS+'\jt.exe'
$path=Split('%PATH%',';')
For Each $jt In $path
ReDim preserve $jtexe[Ubound($jtexe)+1]
$jtexe[Ubound($jtexe)]=Join(Split($jt+'\jt.exe','\\'),'\')
? 'four' +Chr(9)+@ERROR
Next

? 'five' +Chr(9)+@ERROR
; check each filepath for the presence of jt.exe
For Each $jt In $jtexe
If Exist($jt) AND NOT (GetFileAttr($jt) & 16) AND Ubound($jtexe)+1
$jtexe=$jt
? 'six' +Chr(9)+@ERROR
EndIf
Next
Select
Case Ubound($jtexe)+1
Exit 2
Case NOT Exist($jtexe)
Exit 2
? 'seven' +Chr(9)+@ERROR
EndSelect

If Left($comp,2)<>'\\'
$comp='\\'+$comp
? 'eight' +Chr(9)+@ERROR
EndIf

If Right($name,4)<>'.job'
$name=$name+'.job'
? 'nine' +Chr(9)+@ERROR
EndIf

; delete a potentially existing task
$shellcmd = $jtexe
If $user AND $pw
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
? 'ten' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SD "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'

$shellcmd = $jtexe

If $user AND $pw
? 'eleven' +Chr(9)+@ERROR
$shellcmd = $shellcmd+ ' /SC "'+$user+'" "'+$pw+'"'
EndIf

$shellcmd = $shellcmd+ ' /SM '+$comp
$shellcmd = $shellcmd+ ' /SJ ApplicationName="'+$cmd+'"'

If $prms
$shellcmd = $shellcmd+ ' Parameters="'+$prms+'"'
? 'twelve' +Chr(9)+@ERROR
EndIf

$shellcmd = $shellcmd+ ' WorkingDirectory="%SYSTEMROOT%"'
$shellcmd = $shellcmd+ ' Comment="'+$comment+'"'
$shellcmd = $shellcmd+ ' Creator="'+@userid+'"'
$shellcmd = $shellcmd+ ' Priority=Normal'
$shellcmd = $shellcmd+ ' MaxRunTime=3600000'
$shellcmd = $shellcmd+ ' DontStartIfOnBatteries=0'
$shellcmd = $shellcmd+ ' KillIfGoingOnBatteries=0'
$shellcmd = $shellcmd+ ' RunOnlyIfLoggedOn=0'
$shellcmd = $shellcmd+ ' SystemRequired=0'
$shellcmd = $shellcmd+ ' DeleteWhenDone=1'
$shellcmd = $shellcmd+ ' Suspend=0'
$shellcmd = $shellcmd+ ' StartOnlyIfIdle=0'
$shellcmd = $shellcmd+ ' KillOnIdleEnd=0'
$shellcmd = $shellcmd+ ' RestartOnIdleResume=0'
$shellcmd = $shellcmd+ ' Hidden=0'
$shellcmd = $shellcmd+ ' TaskFlags=0'

$shellcmd = $shellcmd+ ' /CTJ StartDate='+$date
$shellcmd = $shellcmd+ ' StartTime='+$time
$shellcmd = $shellcmd+ ' HasEndDate=0'
$shellcmd = $shellcmd+ ' KillAtDuration=0'
$shellcmd = $shellcmd+ ' Disabled=0'
$shellcmd = $shellcmd+ ' Type='+$type
If $typeargs
$shellcmd = $shellcmd+ ' TypeArguments='+$typeargs
? 'thirteen' +Chr(9)+@ERROR
EndIf
$shellcmd = $shellcmd+ ' /SAJ "'+$name+'"'

Shell '%COMSPEC% /e:1024 /c '+$shellcmd+' >NUL 2>NUL'
$scheduletask=@ERROR
? 'fourteen' +Chr(9)+@ERROR
Exit @ERROR
EndFunction


;FUNCTION SerialTime
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;SYNTAX SERIALTIME(STRTIME)
;
;EXAMPLE $rc=SERIALTIME('02:20:33.187')
;
;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

;FUNCTION OSID
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;EXAMPLE $currentos = osid()
; $installdate = CTime($currentos[9])
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000019
;
Function osid(optional $sComp)
Dim $osidarray[11]

Dim $iINWIN, $sDOS, $iBUILD, $sCSD, $iPRODUCTSUITE, $sPRODUCTTYPE


Dim $operating_system, $sp_level, $os_suite, $os_short, $productsuite
Dim $os_type, $os_role, $os_flavor, $os_subver, $regkey
Dim $os_build, $os_proc, $os_owner, $os_org, $os_key, $os_date, $os_oem
Dim $os_lang

$sComp=Trim($sComp)
Select
Case $sComp=@WKSTA
$sComp=''
Case $sComp AND NOT KeyExist('\\'+$sComp+'\HKLM')
Exit 2
Case $sComp
$sComp='\\'+$sComp+'\'
EndSelect

; fetch all macro info depending on whether it's remote or local
If $sComp
If KeyExist($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList')
$iINWIN=1
$sDOS=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CurrentVersion')
$iBUILD=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CurrentBuildNumber')
$sCSD=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','CSDVersion')
If $sDOS='4.0' AND ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\Q246009','Installed')
$sCSD=$sCSD+'a'
EndIf
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions','ProductType')
Select
Case $sPRODUCTTYPE='WinNT'
If $sDOS='4.0'
$sPRODUCTTYPE='Workstation'
Else
$sPRODUCTTYPE='Professional'
EndIf
Case $sPRODUCTTYPE='ServerNT'
If $sDOS='5.2'
$sPRODUCTTYPE=''
Else
$sPRODUCTTYPE='Server'
EndIf
Case $sPRODUCTTYPE='LANManNT'
$sPRODUCTTYPE='Domain Controller'
Case 1
$sPRODUCTTYPE='Home Edition'
EndSelect
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','ProductName')+' '+$sPRODUCTTYPE
$sPRODUCTTYPE=Join(Split($sPRODUCTTYPE,'Microsoft'),'')
$iPRODUCTSUITE=''
$os_lang=$sComp+Join(Split(ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','SystemRoot'),':\'),'$\')+'\system32\shell32.dll'
$os_lang=GetFileVersion($os_lang,'Language')
Else
$iINWIN=2
$dDOS=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','VersionNumber')
$dDOS=Split($dDOS,'.')
$iBUILD=$dDOS[Ubound($dDOS)]
ReDim preserve $dDOS[1]
$sDOS=Join($dDOS,'.')
$sCSD=''
$iPRODUCTSUITE=''
$sPRODUCTTYPE=ReadValue($sComp+'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion','Version')
$os_lang=Right(''+ReadValue($sComp+'HKLM\SYSTEM\CurrentControlSet\Control\Nls\Locale',''),4)
EndIf
Else
$iINWIN=@INWIN
$sDOS=@DOS
$iBUILD=@BUILD
$sCSD=@CSD
$iPRODUCTSUITE=@PRODUCTSUITE
$sPRODUCTTYPE=@PRODUCTTYPE
$os_lang=@SYSLANG
EndIf

; set the correct registry key
If $iINWIN=1
$regkey='HKLM\Software\Microsoft\Windows NT\CurrentVersion'
Else
$regkey='HKLM\Software\Microsoft\Windows\CurrentVersion'
EndIf
If $sComp
$regkey=$sComp+$regkey
EndIf

; retrieve registered owner, organization, build, type
$os_owner=ReadValue($regkey,'RegisteredOwner')
$os_org=ReadValue($regkey,'RegisteredOrganization')
$os_proc=ReadValue($regkey,'CurrentType')
$os_build=Val($iBUILD)

Select
Case $iINWIN=1
; determine the operating system kernel
Select
Case $sDOS='6.0'
$operating_system='Windows Longhorn'
Select
Case $os_build=4015
$operating_system=$operating_system+' (Alpha Preview 3)'
Case $os_build=4008
$operating_system=$operating_system+' (Alpha Preview 2)'
Case 1
$operating_system=$operating_system+' (Alpha/Beta/RC)'
EndSelect
$os_short='WinLonghorn'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='5.2'
$operating_system='Windows Server 2003'
$os_short='Win2K3'
$os_key=ReadValue($regkey,'ProductID')
Select
Case $os_build=3714
$operating_system=$operating_system+' (RC1)'
Case $os_build<3790
$operating_system=$operating_system+' (Alpha/Beta/RC)'
EndSelect
Case $sDOS='5.1'
$operating_system='Windows XP'
Select
Case $os_build=2250
$operating_system=$operating_system+' (Alpha)'
Case $os_build=2257
$operating_system=$operating_system+' (Alpha)'
Case $os_build=2410
$operating_system=$operating_system+' (Beta 1)'
Case $os_build=2416
$operating_system=$operating_system+' (Beta 1)'
Case $os_build=2462
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2465
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2496
$operating_system=$operating_system+' (RC1)'
Case $os_build=2505
$operating_system=$operating_system+' (RC1)'
Case $os_build=2526
$operating_system=$operating_system+' (RC2)'
Case $os_build=2542
$operating_system=$operating_system+' (RC3)'
EndSelect
$os_short='WinXP'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='5.0'
$operating_system='Windows 2000'
Select
Case $os_build=1515
$operating_system=$operating_system+' (Beta 2)'
Case $os_build=2031
$operating_system=$operating_system+' (Beta 3)'
Case $os_build=2128
$operating_system=$operating_system+' (Beta 3 RC2)'
Case $os_build=2183
$operating_system=$operating_system+' (Beta 3)'
EndSelect
$os_short='Win2k'
$os_key=ReadValue($regkey,'ProductID')
Case $sDOS='4.0'
$operating_system='Windows NT 4.0'
$os_short='WinNT'
$os_key=ReadValue($regkey,'ProductID')
$os_key=Left($os_key,5)+'-'+SubStr($os_key,6,3)+'-'+SubStr($os_key,10,7)+'-'+Right($os_key,5)
Case 1
$operating_system='unknown'
$os_short='unknown'
EndSelect

; determine the service pack level
$sp_level=$sCSD
If InStr($sp_level,'Service Pack')
$sp_level=Split($sp_level,'Service Pack')
$sp_level=Trim($sp_level[Ubound($sp_level)])
Else
$sp_level=0
EndIf

; determine the product suite
$productsuite=Val($iPRODUCTSUITE)
$os_suite=''
If $productsuite
If $productsuite & 1
$os_suite=$os_suite+'Small Business |'
EndIf
If $productsuite & 2
$os_suite=$os_suite+'Enterprise |'
EndIf
If $productsuite & 4
$os_suite=$os_suite+'BackOffice |'
EndIf
If $productsuite & 8
$os_suite=$os_suite+'Communication Server |'
EndIf
If $productsuite & 16
$os_suite=$os_suite+'Terminal Server |'
EndIf
If $productsuite & 32
$os_suite=$os_suite+'Small Business (Restricted) |'
EndIf
If $productsuite & 64
$os_suite=$os_suite+'Embedded NT |'
EndIf
If $productsuite & 128
$os_suite=$os_suite+'DataCenter |'
EndIf
If $productsuite & 256
$os_suite=$os_suite+'Single User Terminal Server |'
EndIf
If $productsuite & 512
$os_suite=$os_suite+'Home Edition |'
EndIf
If $productsuite & 1024
$os_suite=$os_suite+'Blade Server |'
EndIf
If InStr($os_suite,'|')
$os_suite=Left($os_suite,Len($os_suite)-2)
EndIf
EndIf

; determine the producy type
$os_type=$sPRODUCTTYPE
Select
Case InStr($os_type,'Domain Controller')
$os_role='Domain Controller'
$os_flavor='Server'
Case InStr($os_type,'Server')
$os_role='Member Server'
$os_flavor='Server'
Case InStr($os_type,'Workstation')
$os_role='Workstation'
$os_flavor='Workstation'
Case InStr($os_type,'Professional')
$os_role='Workstation'
$os_flavor='Workstation'
Case InStr($os_type,'Tablet PC')
$os_role='Workstation'
$os_flavor='Tablet PC'
Case InStr($os_type,'Home Edition')
$os_role='Workstation'
$os_flavor='Workstation'
Case 1
$os_role='unknown'
$os_flavor='unknown'
EndSelect

$operating_system=$operating_system+' '+$os_flavor+' Service Pack '+$sp_level
If $os_suite<>''
$operating_system=$operating_system+' ['+$os_suite+']'
EndIf

; determine the installation date
$os_date=ReadValue('HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion','Installdate')

; determine the OEM Duplicator String
$os_oem=ReadValue('HKLM\System\Setup','OemDuplicatorString')

Case $iINWIN=2
$os_short='Win9x'
$os_role='Workstation'
$sp_level=0

$os_subver=Lcase(ReadValue($regkey,'SubVersionNumber'))

Select
Case $sDOS='4.90'
$operating_system='Windows ME'
$os_key=ReadValue($regkey,'ProductKey')
$os_flavor=''
Case $sDOS='4.10'
$operating_system='Windows 98'
$os_key=ReadValue($regkey,'ProductKey')
Select
Case InStr($os_subver,'c')
$os_flavor='SE'
Case InStr($os_subver,'b')
$os_flavor='B'
Case $os_subver=' a '
$os_flavor='Second Edition'
Case 1
$os_flavor='OEM'
EndSelect
Case $sDOS='4.0'
$operating_system='Windows 95'
$os_key=ReadValue($regkey,'ProductID')
Select
Case InStr($os_subver,'c')
$os_flavor='OSR 2.5'
Case InStr($os_subver,'b')
$os_flavor='OSR 2.0'
Case InStr($os_subver,'a')
$os_flavor=' Service Pack 1'
Case 1
$os_flavor=' OEM'
EndSelect
Case 1
$operating_system='unknown'
$os_short='unknown'
EndSelect

If $os_flavor
$operating_system=$operating_system+' '+$os_flavor
EndIf

EndSelect

$osidarray[0]=$operating_system
$osidarray[1]=$os_short
$osidarray[2]=$os_role
$osidarray[3]=$sp_level
$osidarray[4]=$os_build
$osidarray[5]=$os_proc
$osidarray[6]=$os_owner
$osidarray[7]=$os_org
$osidarray[8]=$os_key
$osidarray[9]=$os_date
$osidarray[10]=$os_oem
$osidarray[11]=$os_lang

$osid=$osidarray

EndFunction

;FUNCTION NetView2()
;
;AUTHOR Jens Meyer (sealeopard@usa.net)
;
;CONTRIBUTOR Shawn Tassie
;
;SYNTAX NetView2([Domain,Comment])
;
;KIXTART BBS http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic;f=12;t=000202
;
Function NetView2(optional $domain, optional $commentflag)
Dim $array[255]
Dim $ReDim, $i, $j, $tempfile
Dim $filehandle, $retcode, $line
Dim $name, $comment

$ReDim = 255
$i = 0
$j = 0
$tempfile = '%temp%\netview.tmp'

If $domain
$domain = '/domain:'+Trim($domain)
EndIf

If VarType($commentflag)
$commentflag=Val($commentflag)
Else
$commentflag=0
EndIf

If Exist($tempfile)
Del $tempfile
EndIf

Shell '%comspec% /c net view '+$domain+' >"'+$tempfile+'"'

If @error = 0
$filehandle=FreeFileHandle()
$retcode=Open($filehandle,$tempfile)

For $j = 1 to 5
$line = ReadLine($filehandle) ; skip headings
Next

While @
_________________________
Co


Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 191 anonymous users online.
Newest Members
thequeen, ameliaryan, shalomsalami, dkdssdk, Vroon
17639 Registered Users

Generated in 0.041 seconds in which 0.014 seconds were spent on a total of 13 queries. Zlib compression enabled.

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