Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

We are using a web based punch in/punch out clock at work, and I only need to double click two nice icons to send the proper commands to the server when I get to work in the morning, and finish work at the evening.

What would be the simplest solution for me to automatically launch the punch in command at first startup each day (note - I may have several restarts during the day, so I don't want to put it in the startup program folder), and to launch the punch out command when I shut down my computer at the evening?

Is there a simple way to identify if the window is being powered up (as opposed to just rebooted)? and powered down (as opposed to restarted)? How and where can I put such a s script?

I am using xp at the moment, but I'd like an option that will also work well on win 7.

Thanks.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

To Windows, "I'm being powered up" and "I'm being rebooted" are the same thing. The OS doesn't know any difference between the two. Hibernation or Sleep modes are different but your midday reboots may actually require a reboot, and a Hibernate or Sleep won't suffice.

Consider this design (steps only; I script in bash). Two scripts, a clock-in script and a clock-out script. Schedule the first to run at login/boot, every time the computer starts. Run the second manually, only when clocking out -- let it shut the computer down for you.

clock-in script

Run this automatically at boot (or login). It can be scheduled with the Windows scheduler, or placed in Startup folder. It'll create a file to indicate that you've clocked in, and won't clock you in again if the file exists when it's run:

  1. Check for the existence of some textfile "C:\username.clocked.in", and exit if found. If not found, continue.
  2. Create the file.
  3. Run the clock-in command.

clock-out script

This script is not automatically run. Instead, it should be run by double-clicking a desktop icon when the user is ready to clock-out and shut down the computer. This script will delete the special file, run the clock-out command, and shutdown the computer.

  1. Delete the lockfile "C:\username.clocked.in".
  2. Run the clock-out command.
  3. Run shutdown -s to shutdown the computer.
share|improve this answer
    
Simple and cool idea. I'll do it later. Thanks :-) –  Noam Gal Nov 11 '09 at 9:45

You can create a batch file with "shutdown /s" command to shutdown the computer. You can trigger this batch file on following occurences in "Task Scheduler" of Windows: at logon, on unlock, on lock, on occurence of an event.

Have a look at various options during task creation for more information.

share|improve this answer

You don't need to create any batch files for this, just schedule these files to be launched at those two specific times of the day using the built-in windows scheduler. This way it doesn't matter if you restart your pc during the day.

share|improve this answer
    
I can add a task "when the computer starts" or "when I log on", but I need to launch it only at the first startup of the day. I also need a task to run at shutdown, and there's not even any other schedule option that resembles it. Is there anything else I can use? –  Noam Gal Nov 11 '09 at 8:58
    
You can use the daily option & enter the time you usually punch in & punch out from work. –  Avis Nov 11 '09 at 11:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.