Hello to all,

i´m developing a script using the clas Win32_ScheduledJob. The method create
of this class allow create Scheduled task in a machine, but, always under the
account LOCALSYSTEM adn also this Scheduled task cannot be modified later.

Can anyone help me??

Thanks in advanced

Re: Scheduling task with other account rather than LOCALSYSTEM by Jason

Jason
Thu Oct 07 15:56:02 CDT 2004

This should get you going. I think you have to register taskscheduler.dll
for it to work.

TimeToRun="18:55"
Dayoftheweek="Sunday"
'CommandtoRun="\\usatas1s\scrub\20clicln.bat /SCRUB"
CommandtoRun="\\fca1\scripts\VBScripts\Tivoli\removetivoli.vbs"


Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

SuccessFile="Success.txt"
BadFile="Bad.txt"
Set theArgs=WScript.Arguments
Domain=theArgs.item(0)
ServiceAccount=theArgs.item(1)
Password=theArgs.item(2)

Dim objSubKey
Dim objRegRootKey
Dim objRemoteRegistry

'Successful Password Resets
Set fsGood=CreateObject("Scripting.FileSystemObject")
Set Success=fsGood.OpenTextFile(SuccessFile, ForWriting, True)

'Failed Password Resets
Set fsBad=CreateObject("Scripting.FileSystemObject")
Set Bad=fsBad.OpenTextFile(BadFile, ForWriting, True)


Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTextStream = oFSO.OpenTextFile("srvlist.txt")
x=0
Do While oTextStream.AtEndOfStream <> TRUE
Redim Preserve aSrvlist(x)
strServer = oTextStream.ReadLine
aSrvlist(x)=RTrim(strServer)
x=x+1
Loop
oTextStream.Close




Set Registry = CreateObject("RegObj.Registry")


For Each Server in aSrvlist
Wscript.echo Server
Scheduler(CommandtoRun)
Account=Domain & "\" & ServiceAccount
Domain=UCase(Domain)
ServiceAccount=UCase(ServiceAccount)
SetTasks()
Next




Sub Scheduler (Path)
Set ws=Wscript.CreateObject("WScript.Shell")
'Commandline="at \\" & Server & " " & TimeToRun & " /Next:" + Dayoftheweek+
" " + Chr(34)+ Path + Chr(34)
Commandline="at \\" & Server & " " & TimeToRun & " /Next:" + Dayoftheweek+
" " + Path
Wscript.echo Commandline
ret=ws.Run(Commandline,0, "TRUE")
If(ret=0) Then
Wscript.echo "Task Scheduled Successfully " & Server
Success.WriteLine "Task Scheduled Successfully " & Server
Else
Wscript.echo "Task Failed " & Server
Bad.WriteLine "Task Failed " & Server
End If
End Sub


Sub SetTasks
On Error Resume Next
Set MyTasks = Wscript.CreateObject("Scheduler.SchedulingAgent.1")
Wscript.echo "Running setTasks against " & Server
UNCServer="\\"&Server
MyTasks.TargetComputer="" &UNCServer & ""
If (Err.Number <>0) Then
Exit Sub
End If
Err.Clear
For Each objTask in MyTasks.Tasks
servacct=UCase(objTask.AccountName)
If (IsNull(servacct)) Then
objTask.SetAccountInformation Account,Password
If (Err.Number <> 0) Then
If(UCase(objTask.JobName) <>UCase("Calculator.job")) Then
Bad.WriteLine objTask.JobName & "Error Number" & Err.Number & Chr(13)
& Err.Description
wscript.echo Server & objTask.JobName & "Error Number" & Err.Number &
Chr(13) & Err.Description
Else

End If
Else
Success.WriteLine MyTasks.TargetComputer & ":" & objTask.JobName & ":OK"
Wscript.echo MyTasks.TargetComputer & ":" & objTask.JobName & ":OK"
End If
Else
Xtra.WriteLine "\\" & Server & ":" & objTask.JobName & ":" &
objTask.AccountName
Wscript.echo "\\" & Server & ":" & objTask.JobName & ":" &
objTask.AccountName
End If

Next




End Sub
"Eduardo Martin (Spain)" <Eduardo Martin (Spain)@discussions.microsoft.com>
wrote in message news:471A2180-C8ED-4AF5-B54C-7BF2C9AEB762@microsoft.com...
> Hello to all,
>
> i´m developing a script using the clas Win32_ScheduledJob. The method
> create
> of this class allow create Scheduled task in a machine, but, always under
> the
> account LOCALSYSTEM adn also this Scheduled task cannot be modified later.
>
> Can anyone help me??
>
> Thanks in advanced



Re: Scheduling task with other account rather than LOCALSYSTEM by Eduardo

Eduardo
Thu Oct 07 16:21:01 CDT 2004

I´m viewing that you are using the at command instead the WMI class/method.
This is very useful for me, but , only one question more, wath are yoy saying
about taskscheduler.dll

"Jason Stanley" wrote:

> This should get you going. I think you have to register taskscheduler.dll
> for it to work.
>
> TimeToRun="18:55"
> Dayoftheweek="Sunday"
> 'CommandtoRun="\\usatas1s\scrub\20clicln.bat /SCRUB"
> CommandtoRun="\\fca1\scripts\VBScripts\Tivoli\removetivoli.vbs"
>
>
> Const ForReading = 1
> Const ForWriting = 2
> Const ForAppending = 8
>
> SuccessFile="Success.txt"
> BadFile="Bad.txt"
> Set theArgs=WScript.Arguments
> Domain=theArgs.item(0)
> ServiceAccount=theArgs.item(1)
> Password=theArgs.item(2)
>
> Dim objSubKey
> Dim objRegRootKey
> Dim objRemoteRegistry
>
> 'Successful Password Resets
> Set fsGood=CreateObject("Scripting.FileSystemObject")
> Set Success=fsGood.OpenTextFile(SuccessFile, ForWriting, True)
>
> 'Failed Password Resets
> Set fsBad=CreateObject("Scripting.FileSystemObject")
> Set Bad=fsBad.OpenTextFile(BadFile, ForWriting, True)
>
>
> Set oFSO = CreateObject("Scripting.FileSystemObject")
> Set oTextStream = oFSO.OpenTextFile("srvlist.txt")
> x=0
> Do While oTextStream.AtEndOfStream <> TRUE
> Redim Preserve aSrvlist(x)
> strServer = oTextStream.ReadLine
> aSrvlist(x)=RTrim(strServer)
> x=x+1
> Loop
> oTextStream.Close
>
>
>
>
> Set Registry = CreateObject("RegObj.Registry")
>
>
> For Each Server in aSrvlist
> Wscript.echo Server
> Scheduler(CommandtoRun)
> Account=Domain & "\" & ServiceAccount
> Domain=UCase(Domain)
> ServiceAccount=UCase(ServiceAccount)
> SetTasks()
> Next
>
>
>
>
> Sub Scheduler (Path)
> Set ws=Wscript.CreateObject("WScript.Shell")
> 'Commandline="at \\" & Server & " " & TimeToRun & " /Next:" + Dayoftheweek+
> " " + Chr(34)+ Path + Chr(34)
> Commandline="at \\" & Server & " " & TimeToRun & " /Next:" + Dayoftheweek+
> " " + Path
> Wscript.echo Commandline
> ret=ws.Run(Commandline,0, "TRUE")
> If(ret=0) Then
> Wscript.echo "Task Scheduled Successfully " & Server
> Success.WriteLine "Task Scheduled Successfully " & Server
> Else
> Wscript.echo "Task Failed " & Server
> Bad.WriteLine "Task Failed " & Server
> End If
> End Sub
>
>
> Sub SetTasks
> On Error Resume Next
> Set MyTasks = Wscript.CreateObject("Scheduler.SchedulingAgent.1")
> Wscript.echo "Running setTasks against " & Server
> UNCServer="\\"&Server
> MyTasks.TargetComputer="" &UNCServer & ""
> If (Err.Number <>0) Then
> Exit Sub
> End If
> Err.Clear
> For Each objTask in MyTasks.Tasks
> servacct=UCase(objTask.AccountName)
> If (IsNull(servacct)) Then
> objTask.SetAccountInformation Account,Password
> If (Err.Number <> 0) Then
> If(UCase(objTask.JobName) <>UCase("Calculator.job")) Then
> Bad.WriteLine objTask.JobName & "Error Number" & Err.Number & Chr(13)
> & Err.Description
> wscript.echo Server & objTask.JobName & "Error Number" & Err.Number &
> Chr(13) & Err.Description
> Else
>
> End If
> Else
> Success.WriteLine MyTasks.TargetComputer & ":" & objTask.JobName & ":OK"
> Wscript.echo MyTasks.TargetComputer & ":" & objTask.JobName & ":OK"
> End If
> Else
> Xtra.WriteLine "\\" & Server & ":" & objTask.JobName & ":" &
> objTask.AccountName
> Wscript.echo "\\" & Server & ":" & objTask.JobName & ":" &
> objTask.AccountName
> End If
>
> Next
>
>
>
>
> End Sub
> "Eduardo Martin (Spain)" <Eduardo Martin (Spain)@discussions.microsoft.com>
> wrote in message news:471A2180-C8ED-4AF5-B54C-7BF2C9AEB762@microsoft.com...
> > Hello to all,
> >
> > i´m developing a script using the clas Win32_ScheduledJob. The method
> > create
> > of this class allow create Scheduled task in a machine, but, always under
> > the
> > account LOCALSYSTEM adn also this Scheduled task cannot be modified later.
> >
> > Can anyone help me??
> >
> > Thanks in advanced
>
>
>

Re: Scheduling task with other account rather than LOCALSYSTEM by tlviewer

tlviewer
Thu Oct 07 21:04:14 CDT 2004


"Jason Stanley" <jlstanleyNoSpam@mmm.com> wrote in message =
news:uiadPALrEHA.3868@TK2MSFTNGP15.phx.gbl...
> This should get you going. I think you have to register =
taskscheduler.dll=20
> for it to work.

This DLL is from Site Server, right? At first I thought it was
Edanmo's but there is no separate method to refresh the
Task collection.

It certainly isn't the DLL I maintain.
This is the first evidence I've ever seen that anyone uses
the Site Server mstask automater.

What exactly does the removetivoli.vbs script do?

thanks for posting this,
tlviewer
>=20
> TimeToRun=3D"18:55"
> Dayoftheweek=3D"Sunday"
> 'CommandtoRun=3D"\\usatas1s\scrub\20clicln.bat /SCRUB"
> CommandtoRun=3D"\\fca1\scripts\VBScripts\Tivoli\removetivoli.vbs"
>=20
>=20
=20
> Sub SetTasks
> On Error Resume Next
> Set MyTasks =3D Wscript.CreateObject("Scheduler.SchedulingAgent.1")
> Wscript.echo "Running setTasks against " & Server
<snip>
>=20
> End Sub
> "Eduardo Martin (Spain)" <Eduardo Martin =
(Spain)@discussions.microsoft.com>=20
> wrote in message =
news:471A2180-C8ED-4AF5-B54C-7BF2C9AEB762@microsoft.com...
> > Hello to all,
> >
> > i=B4m developing a script using the clas Win32_ScheduledJob. The =
method=20
> > create
> > of this class allow create Scheduled task in a machine, but, always =
under=20
> > the
> > account LOCALSYSTEM adn also this Scheduled task cannot be modified =
later.
> >
> > Can anyone help me??
> >
> > Thanks in advanced=20
>=20
>

Re: Scheduling task with other account rather than LOCALSYSTEM by Jason

Jason
Fri Oct 08 08:10:45 CDT 2004

All removetivoli is, is an example of a task that can be scheduled. You can
replace it with anything. If you don't have the taskscheduler dll let me
know and I'll get it to you.

Jason


"tlviewer" <tlviewerSHRUB@yahooCHENEY.com> wrote in message
news:OeMinsNrEHA.3488@TK2MSFTNGP11.phx.gbl...

"Jason Stanley" <jlstanleyNoSpam@mmm.com> wrote in message
news:uiadPALrEHA.3868@TK2MSFTNGP15.phx.gbl...
> This should get you going. I think you have to register taskscheduler.dll
> for it to work.

This DLL is from Site Server, right? At first I thought it was
Edanmo's but there is no separate method to refresh the
Task collection.

It certainly isn't the DLL I maintain.
This is the first evidence I've ever seen that anyone uses
the Site Server mstask automater.

What exactly does the removetivoli.vbs script do?

thanks for posting this,
tlviewer
>
> TimeToRun="18:55"
> Dayoftheweek="Sunday"
> 'CommandtoRun="\\usatas1s\scrub\20clicln.bat /SCRUB"
> CommandtoRun="\\fca1\scripts\VBScripts\Tivoli\removetivoli.vbs"
>
>

> Sub SetTasks
> On Error Resume Next
> Set MyTasks = Wscript.CreateObject("Scheduler.SchedulingAgent.1")
> Wscript.echo "Running setTasks against " & Server
<snip>
>
> End Sub
> "Eduardo Martin (Spain)" <Eduardo Martin
> (Spain)@discussions.microsoft.com>
> wrote in message
> news:471A2180-C8ED-4AF5-B54C-7BF2C9AEB762@microsoft.com...
> > Hello to all,
> >
> > i´m developing a script using the clas Win32_ScheduledJob. The method
> > create
> > of this class allow create Scheduled task in a machine, but, always
> > under
> > the
> > account LOCALSYSTEM adn also this Scheduled task cannot be modified
> > later.
> >
> > Can anyone help me??
> >
> > Thanks in advanced
>
>