sunhux
asked on
Windows batch or VB script : check if oldest file in folder is more than 50 secs
Print jobs in our Win 2003 occasionally got stuck. Generally, a print
job spooled will be printed within half a minute & at any one time,
we've always seen one print job that's causing the problem (not
seen any multiple print job causing problem at any one time yet).
A print job will create one .spl & one .shd file to the folllowing folder:
C:\Windows\System32\Spool\ Printers
For this example, say, we have 3 print jobs:
abc.spl & abc.shd
bcd.spl & bcd.shd
cde.spl & cde.shd
I'll need a script (that I'll run every minute using Windows scheduler)
to check for the oldest (modified date/time) .spl to see if it is more
than 50 secs old.
If the oldest .spl file (take for example it's abc.spl in this case) is
more than 50 secs old, the script will
a) move abc.spl & abc.shd to c:\temp\stuckjob\ folder &
b) move the rest of the files (in this case, it's bcd.* & cde.*)
to c:\temp\goodjob\ folder
c) then restart the print spooler (ie issue 'sc stop spooler'
followed by 'sc start spooler'
d) move back c:\temp\goodjob\*.* to
C:\Windows\System32\Spool\ Printers folder
job spooled will be printed within half a minute & at any one time,
we've always seen one print job that's causing the problem (not
seen any multiple print job causing problem at any one time yet).
A print job will create one .spl & one .shd file to the folllowing folder:
C:\Windows\System32\Spool\
For this example, say, we have 3 print jobs:
abc.spl & abc.shd
bcd.spl & bcd.shd
cde.spl & cde.shd
I'll need a script (that I'll run every minute using Windows scheduler)
to check for the oldest (modified date/time) .spl to see if it is more
than 50 secs old.
If the oldest .spl file (take for example it's abc.spl in this case) is
more than 50 secs old, the script will
a) move abc.spl & abc.shd to c:\temp\stuckjob\ folder &
b) move the rest of the files (in this case, it's bcd.* & cde.*)
to c:\temp\goodjob\ folder
c) then restart the print spooler (ie issue 'sc stop spooler'
followed by 'sc start spooler'
d) move back c:\temp\goodjob\*.* to
C:\Windows\System32\Spool\
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You'll need to download it. Windows Update should provide it as optional update.
ASKER
one incident of a job being stuck & held up all other jobs in the spooler.
No specific error code in Event viewer too.
Is PowerShell available in Win 2003 or I need to install a PowerShell?