If you are using Win-7 you can do that in task scheduler.
Open the task scheduler, select My Task Schedules, and choose Create Task (not create basic task).
Give it a name, click the Actions tab and choose the program you want to run
Choose the Conditions tab, click on "run if idle for xxx minutes", and check stop runing if computer ceases to be idle.
That should do it.