Discussion Locked

Using Scheduled Tasks

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

We are looking to find a way to use the "Scheduled Tasks" feature in Windows 2000 to open a document at a scheduled time and then print it, or an inexpensive product that would do this. Please be as specific as possible as to the set up, I have a very limited experience with scripting.

Thanks

7 replies

by whw

Windows Scripting Host is your solution.
Which if your running 2000, should already be installed.

You didn't say what "type" of document so I'm going to ASSUME a word document.

First, login to the machine to which the printer is connected as the local administrator.

Next, let's create WordPrint.vbs
(You may cut&paste, but do not include the dashes)
------------------------------------------------
' WordPrint.vbs
' Word needs to be installed on this machine
Dim DocToPrint, oWord, oDoc
DocToPrint = "M:\whatever.doc"
Set oWord = CreateObject("Word.Application")
Set oWordActiveDoc = oWord.Documents.Open("" & DocToPrint)
oWordActiveDoc.PrintOut
Set oWord = Nothing
WScript.Quit(0)
-------------------------------------------------
Is it saved?
OK, now let's create the task.
Open scheduled tasks, we don't want to run the wizard so just right-click, new|scheduled task, and give it a name. Right-click on the new task, select properties.

RUN:
C:\WINNT\system32\cscript.exe "M:\pathto\WordPrint.vbs"

Click Schedule and set it.

Adjust the Settings tab if needed.

Finally, Adjust the Security tab... we want this to run regardless of whose logged in, so click
Add. Add either everyone or authenticated users depending on your needs, click ok and make sure that ONLY the block read and execute is checked. Other users won't need to modify this.

Click Apply, enter your password and your done.

You could right-click the new task and select run to check.

HIH

by whw

IMPORTANT SECURITY NOTE:
WordPrint.vbs MUST be made READ-ONLY. Change its perms if needed so that everyone or authenticated users may only READ it. Otherwise, it could be modified and you just gave admin access to the hacker.

Also, since we're cutting and pasting here, in WordPrint.vbs make sure to change DocToPrint to the correct document.

by whw

Ok, replace WordPrint.vbs with ExcelPrint.vbs below.

Also, remember to adjust the permissions under the Security tab for this file accordingly, so that it is READ-ONLY to everyone or authenticated users as mentioned above.

Adjust the DocToPrint, and TabsToPrint in the script as needed.

Finally, adjust your scheduled task to point to ExcelPrint.vbs instead of WordPrint.vbs

cut & paste here, but do not include the dashes
----------------------------------
' ExcelPrint.vbs
' Excel needs to be installed on this machine
Dim DocToPrint, TabsToPrint, t, oXL, oWb
DocToPrint = "M:\whatever.xls"
TabsToPrint = Array("Test","Sheet1") 'set to the names of your worksheet tabs
Set oXL = CreateObject("Excel.Application")
Set oWb =oXL.WorkBooks.Open("" & DocToPrint)
For t=0 TO UBOUND(TabsToPrint)
Set oWb = oXL.ActiveWorkBook.WorkSheets("" & TabsToPrint(t))
oWb.Activate
oXL.ActiveSheet.PrintOut ' print Worksheet
Next
oXL.Quit ' Quit Excel
Set objXL = Nothing
WScript.Quit(0)
----------------------------------

by whw

small typo on my part.
Please change next to last line
Set objXL = Nothing
to
Set oXL = Nothing

by dave the computer guy

Thank you WhW.

I'm trying to print an excel speadsheet not a word document. Can you tell me what I need to change in the script.

Thanks again.

This discussion is closed to new replies.