Results 1 to 11 of 11

Thread: scheduled printing of a text file using batch files or schtasks

  1. #1
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7

    scheduled printing of a text file using batch files or schtasks

    I've been attempting to automate the process of printing a text file using a batch file or schtasks in the command line, in order to provide a "warm up" method (test page) for our networked Xerox printer.
    The printer has issues with time outs, after 240 minutes of non use. It then takes 30 seconds to 5 minutes (depending upon the settings in place) for the printer to warm up, before it will print. I can obviously use the software or hardware process to do such, but I have better things to do with my time.

    Printing from the command line using notepad works fine!

    (Code String Example:)
    notepad /p desktop\blank.txt


    I am stumped on using the proper syntax method for the command line when attempting to use the "schtasks" for automating this process.

    (Code String EXAMPLE:)
    schtasks /create /s /tn "Printer Warm Up" /tr notepad /p desktop\blank.txt /sc daily /st 10:00:00 /ed 06/06/2008

    I receive the following error:

    ERROR: Invalid syntax. Value expected for '/s'



    I've tried many different ways of moving the "/s" around to make this work, but it always complains about the string in place.

    Other ERROR: Cannot specify password without specifying the user name.

    There should be an easier way to specify the local system, without user name and password?

    ANY IDEAS?
    (Besides dumping the Xerox printer...LOL)
    Last edited by Gadgetman; 06-06-2008 at 12:28 AM. Reason: attempting to narrow down the better task at hand

  2. #2
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    *Note - this is using Windows XP Pro

  3. #3
    Join Date
    Nov 2005
    Posts
    3,026

    Re: scheduled printing of a text file using batch files

    I think that the question that you are asking is for a scheduled task rather than a printing question. So, I have never used the schtasks command till now. There might be someone who can help you out.

  4. #4
    Join Date
    Nov 2005
    Posts
    625

    Re: scheduled printing of a text file using batch files

    I am also not a scheduled task expert but in looking at the syntax for the schtasks command and the /S switch, I think that if you use this switch you should provide a remote system argument for it, your example has no remote system argument defined. Incase you leave the /S out, help indicates the system parameter defaults to the local system. The /P switch would require a /U username if used. It seems like using /RP System would run everything under the system account.

  5. #5
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    (Code String Example:)
    notepad /p desktop\blank.txt

    In the above example, you should be able to print without specifying anything else. (System, Printer, Username and Password shouldn't be required.)

    However, if you use "SCHTASKS" the "/P" takes on a whole new meaning.
    ("/P" would then indicate PASSWORD, and using "/P" switch would probably require a /U username if used.)

  6. #6
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    "lpr -S ip_address -P lpt1 wakeup.txt"

    This works Great Also, and appears to be yet another way to print from the command line. (Thanks for providing another way to do such, I'm always learning! Appreciate your input!)

    It's very similar to the original command used: notepad /p desktop\blank.txt
    (Which works fine if I manually type in the command)

    Does anyone know how to apply this using "SCHTASKS" ?

    Or possibly open my eyes to using a Batch File for the commands to run at specific times?


    I really appreciate all suggestions and efforts!

    Thanks Again!

  7. #7
    Join Date
    Nov 2005
    Posts
    609

    Re: scheduled printing of a text file using batch files or schtasks

    Yeah, but it would require a printer driver, the lpr command sends a raw file to the printer. Why dont you use the GUI to add the batch job?

  8. #8
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    Another excellent result of using this command:
    "lpr -S ip_address -P lpt1 wakeup.txt"
    is that it spools the print job "blank.txt" without printing any actual data!
    (This means that we can re-use the paper, since it remains blank.)
    Something I was unable to do using the previous command:
    "notepad /p desktop\blank.txt"
    (which always required some data within the text file, and also printed "Page 1" at the bottom regardless.
    Now if I can only figure out how to automate the process, so it will do this every morning, and every 239 minutes until 7pm M-F!

  9. #9
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    Funny you should mention that, as I'm attempting to create a working batch file which will execute the command line:"lpr -S ip_address -P lpt1 wakeup.txt"
    using the GUI "Scheduled Tasks" within XP.
    (If successful, it will most likely run using "AT" or "SCHTASKS" as well.)

    Just having trouble writing this Batch File (My first batch file) to execute properly.
    The batch file appears to run, but nothing occurs.

    Yet typing: "lpr -S ip_address -P lpt1 wakeup.txt" in the command manually, it executes flawlessly. (The printer spools!)

    Any Ideas / Suggestions?

  10. #10
    Join Date
    Nov 2005
    Posts
    709

    Re: scheduled printing of a text file using batch files or schtasks

    You can try to use the below:

    schtasks /create /tn "Printer warm up" /sc weekly /ri 239 /d
    mon,tue,wed,thu,fri /st 10:00:00 /et 19:00:00 /tr c:\batch\wakeup.cmd
    /ru username /rp password

    It will only work on Server 2003 and XP will not support all the schtasks options. Also, I usually never put arguments in the command for a task, I would like to launch a batch file with all the codings in it.

  11. #11
    Join Date
    Jun 2008
    Location
    Pagosa Springs,Co
    Posts
    7
    The only problem I still face is the actual batch file not executing.
    I've tried it several different ways, using a "warmup.bat" and also "warmup.cmd" file to reference in the cmd string. The schtasks command string fires, yet nothing occurs at the printer end. I've narrowed it down to the .bat & .cmd file not executing: lpr -S MyIP_address -P 8550dp blank.txt

    Yet if I manually type the same command in the CMD prompt, it works?

    As stated previously, I'm new to creating batch files...
    So it must be my lack of knowledge of syntax for creating a proper batch file.

    I'm still experimenting...

Similar Threads

  1. Editing text file using a batch file
    By beelow in forum Software Development
    Replies: 8
    Last Post: 09-03-2010, 12:27 AM
  2. DSMOD from batch and text file
    By BUKSIS in forum Active Directory
    Replies: 2
    Last Post: 03-03-2010, 10:07 PM
  3. batch file to split multiple text files in half.
    By yammyguy in forum Windows Server Help
    Replies: 8
    Last Post: 11-05-2009, 06:19 PM
  4. Problems running batch file as scheduled task
    By pete0085 in forum Windows Server Help
    Replies: 7
    Last Post: 01-01-2009, 03:15 PM
  5. Replies: 7
    Last Post: 09-03-2008, 05:56 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,260,067.82621 seconds with 17 queries