Scheduling Tasks from a Command Line in Windows Vista and XP

I’d like to start this post with a warning: I’m only 29 years old but already have permanent damage to my shoulder caused by overusage while working/playing on the computer. Two years ago, I had to claim workman’s comp because I was disabled for a few weeks, barely being able to even stand because of an excruciating pain in my shoulder – even gravity put too much pressure on it. I didn’t know what was happening at first, I thought it just needed to “pop” but as it turned out, I had tendonitis/bursitis from repetitive mouse/keyboard usage. While the damage was permanent, the pain went away after a terribly painful cortisone shot was injected right into my shoulder. By that time, calcium had built up and I heard the needle crush right through it. Ugh, even with lots of Vicodin and some other topical pain killer, it was still unbelievably painful.

To stop the problem from recurring, I had my desk evaluated by an ergonomic specialist and ended up buying a new chair and a new keyboard tray. I also moved my mouse in closer to my body so that I wouldn’t have to reach so far out. I got tips on how to sit, stretch, mouse, etc. I suggest that if you haven’t had an ergo eval recently, ask your company to schedule one with a professional. The time I’ve invested at physical therapy, at the doctor’s office, icing my shoulder, figuring out how to clean/cook with a bum shoulder, buying new backpacks, etc could have been avoided if I got into a healthy posture habit when I first started working on computers. So now.. I ice, take lots of ibuprofin and perform stretches.

Everyone, not just fools like me with bum shoulders, should stretch at least once an hour while on their computer. I’m pretty forgetful but even if I wasn’t, I don’t think its possible to remember to stretch every hour on the hour without some help. And this is where the command line task scheduling fun comes in.

Often times, I’ve scheduled tasks in both Windows and Unix from the command line using at. Today while researching creating a stretch task, I learned that Microsoft replaced at with schtasks and Apple replaced at with launchd. Works for me, Windows’ at doesn’t really support hourly tasks while schtasks does. Below is a scheduled task that I’m running in order to prevent further injury to my shoulder:

schtasks /create /tn StretchReminder /tr “msg console Stretch!” /sc HOURLY

Using this command, I’ve created a task to run once an hour which sends me a simple message that reads “Stretch!” You may wonder why I’m not using net send. The reason is that net send is no longer supported in Vista and msg is supported in both XP and Vista.

Here’s hoping my shoulder gets better and yours never starts acting up.

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in Windows
3 comments on “Scheduling Tasks from a Command Line in Windows Vista and XP
  1. Fred says:

    Thanks for the tips ^_^

    I came in to figure out how to configure task scheduler with command line, I end up on stretch websites :)
    I am sure I am using howful posture to work, but I am more worried about my back….

    Hoping you’ll keep up even with your bad injury

    Fred

  2. MATT says:

    I had a similar problem with my wrist and neck from repetitive motion and an old sports injury, respectively. I try to stay away from a mouse and use the keyboard whenever possible. I also will change positions regularly to prevent the EXACT same motion. For instance, raising or lowering the chair, changing monitor hieghts, moving the keyboard closer and farther away, and using the mouse on left and right.

  3. globulon says:

    thanx a lot, was very helpful

Leave a Reply

Your email address will not be published. Required fields are marked *

*