Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.


Go Back   Vista Forums > Misc Newsgroups > VB Script

RB

Vista - Scheduling scripts

Reply
 
11-01-2008   #1
Jeff C


 
 

Scheduling scripts

I have numerous (40-50) processes; batch files, vbs files, and command lines,
and the collection is growing. They are being executed using the windows
task scheduler in Windows server 2003.
There is a 2 hour window between 5 and 7 AM every morning when I want
everything to run but I am concerned about tasks being scheduled close
together possibly causing processes to run at the same time.

Will this cause errors or will the system handle it? Is there code that can
be used that will cause a scheduled task to wait until the system is free
before it runs eliminating an error?

Self taught here looking for an education. Thanks in advance.
--
Jeff C
Live Well .. Be Happy In All You Do

My System SpecsSystem Spec
11-01-2008   #2
Pegasus \(MVP\)


 
 

Re: Scheduling scripts


"Jeff C" <JeffC@xxxxxx> wrote in message
news:0BE1BD58-C56B-47D5-97DA-3EF19D6F5AD4@xxxxxx
Quote:

>I have numerous (40-50) processes; batch files, vbs files, and command
>lines,
> and the collection is growing. They are being executed using the windows
> task scheduler in Windows server 2003.
> There is a 2 hour window between 5 and 7 AM every morning when I want
> everything to run but I am concerned about tasks being scheduled close
> together possibly causing processes to run at the same time.
>
> Will this cause errors or will the system handle it? Is there code that
> can
> be used that will cause a scheduled task to wait until the system is free
> before it runs eliminating an error?
>
> Self taught here looking for an education. Thanks in advance.
> --
> Jeff C
> Live Well .. Be Happy In All You Do
Since Windows is a multitasking OS, you can run several tasks at the same
time, as long as they do not use the same resource(s) exclusively. You
could, of course, run them consecutively by invoking one after the other
from a master batch file.


My System SpecsSystem Spec
11-01-2008   #3
James Whitlow


 
 

Re: Scheduling scripts

"Jeff C" <JeffC@xxxxxx> wrote in message
news:0BE1BD58-C56B-47D5-97DA-3EF19D6F5AD4@xxxxxx
Quote:

>I have numerous (40-50) processes; batch files, vbs files, and command
>lines,
> and the collection is growing. They are being executed using the windows
> task scheduler in Windows server 2003.
> There is a 2 hour window between 5 and 7 AM every morning when I want
> everything to run but I am concerned about tasks being scheduled close
> together possibly causing processes to run at the same time.
>
> Will this cause errors or will the system handle it? Is there code that
> can
> be used that will cause a scheduled task to wait until the system is free
> before it runs eliminating an error?
Whether the system can handle it or not is going to really depend on the
batch and script files themselves. Also, are there any dependancies for one
script to run before the other?

Task Scheduler does support an 'onidle' switch. You can specify how long
you want the computer to be idle before the task runs.

One thing you might want to consider it creating a mast script to
execute your other scripts. A few options would be to put all of your
scripts into a common directory, create a text file with a list of your
scripts, create a WSF file with script listed in a resource. Examples below:

The first example, "MasterDir.vbs" would execute everything in
'C:\Scripts', waiting for it to complete before continuing on.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWSH = CreateObject("WScript.Shell")

sScriptDir = "C:\Scripts"

If Not oFSO.FolderExists(sScriptDir) Then WScript.Quit

Set oScriptDir = oFSO.GetFolder(sScriptDir)

For Each sScript in oScriptDir.Files
oWSH.Run """" & sScript & """", 1, True
Next
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The second example, "MasterList.vbs" would execute a list of scripts in
a text file at 'c:\script.txt'

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oWSH = CreateObject("WScript.Shell")

sScriptList = "C:\Scripts.txt"

If Not oFSO.FileExists(sScriptList) Then WScript.Quit

With oFSO.OpenTextFile(sScriptList)
aScripts = Split(.ReadAll, vbCrLf)
End With

For Each sScript in aScripts
If oFSO.FileExists(sScript) Then
oWSH.Run """" & sScript & """", 1, True
End If
Next
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The last example, "Resource.wsf" uses an list of script embeded into a
<resource> tag in the script. Be careful to give it a 'wsf' extension and
not 'vbs'.

<?xml version="1.0" encoding="ISO-8859-1"?>

<job>
<resource id="scripts">
C:\Windows\system32\notepad.exe
C:\Program Files\Windows NT\Accessories\wordpad.exe
</resource>
<object id="oWSH" progid="WScript.Shell"/>
<object id="oFSO" progid="Scripting.FileSystemObject"/>
<script language="VBScript"><![CDATA[
sScriptList = GetResource("scripts")
aScripts = Split(sScriptList, vbCrLf)
For Each sScript in aScripts
If oFSO.FileExists(sScript) Then
oWSH.Run """" & sScript & """", 1, True
End If
Next
]]></script>
</job>


My System SpecsSystem Spec
11-01-2008   #4
Python


 
 

Re: Scheduling scripts

I just retired from a real-time environment where I had to coordinate the
execution of around 100 separate tasks (scripts, exes, etc). Because these
tasks were critical, we decided to go with a third party product to schedule
them. We originally used Arcana Scheduler
(http://www.arcanadev.com/products/) and later upgraded to adTempus (dame
company). adTempus will run $500 for one copy (extra licences are available
for less than the single unit cost). Arcana Scheduler will cost around $50
and will probably suit your needs. The reason we went for the more expensive
option was

1) I worked for a large firm where the difference in price was insignificant
2) adTempus had a folder watch trigger so we could run tasks when files
appeared in folders

Check out the fetures of Arcana Scheduler. I'm sure it will suit your needs
admirably. The company's tech support is the best I've seen in the business.
For %50 it's just not worth it to write and debug your own scheduler.

PS - I don't get a kickback; I'm, just an extremely satisfied customer.



"Jeff C" <JeffC@xxxxxx> wrote in message
news:0BE1BD58-C56B-47D5-97DA-3EF19D6F5AD4@xxxxxx
Quote:

>I have numerous (40-50) processes; batch files, vbs files, and command
>lines,
> and the collection is growing. They are being executed using the windows
> task scheduler in Windows server 2003.
> There is a 2 hour window between 5 and 7 AM every morning when I want
> everything to run but I am concerned about tasks being scheduled close
> together possibly causing processes to run at the same time.
>
> Will this cause errors or will the system handle it? Is there code that
> can
> be used that will cause a scheduled task to wait until the system is free
> before it runs eliminating an error?
>
> Self taught here looking for an education. Thanks in advance.
> --
> Jeff C
> Live Well .. Be Happy In All You Do

My System SpecsSystem Spec
11-01-2008   #5
Jeff C


 
 

Re: Scheduling scripts


--
Jeff C
Live Well .. Be Happy In All You Do


"Pegasus (MVP)" wrote:
Quote:

>
> "Jeff C" <JeffC@xxxxxx> wrote in message
> news:0BE1BD58-C56B-47D5-97DA-3EF19D6F5AD4@xxxxxx
Quote:

> >I have numerous (40-50) processes; batch files, vbs files, and command
> >lines,
> > and the collection is growing. They are being executed using the windows
> > task scheduler in Windows server 2003.
> > There is a 2 hour window between 5 and 7 AM every morning when I want
> > everything to run but I am concerned about tasks being scheduled close
> > together possibly causing processes to run at the same time.
> >
> > Will this cause errors or will the system handle it? Is there code that
> > can
> > be used that will cause a scheduled task to wait until the system is free
> > before it runs eliminating an error?
> >
> > Self taught here looking for an education. Thanks in advance.
> > --
> > Jeff C
> > Live Well .. Be Happy In All You Do
>
> Since Windows is a multitasking OS, you can run several tasks at the same
> time, as long as they do not use the same resource(s) exclusively. You
> could, of course, run them consecutively by invoking one after the other
> from a master batch file.
>
>
> Thanks to Pegasus, James and Python. I appreciate the feedback and ideas, I try your suggestions.
My System SpecsSystem Spec
Reply

RB


Thread Tools


Similar Threads for: Scheduling scripts
Thread Forum
run .cmd scripts on remote machine (automating the MOSS install via scripts) PowerShell
window scheduling Vista General
Scheduling Tasks vs UAC Vista security
SyncToy Scheduling Vista General
Scheduling running of PowerShell Scripts PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd