run command/script when lock/unlock windows station? - windows

I have Windows 7 pro at work. My problem is I keep on forgetting to clock in/clock out (using the intranet timesheet system). Is there a way to run a script or command to automatically open the timesheet page each time I lock/unlock my station?

Yes, windows 7 task scheduler allows a dizzying array of new ways to schedule tasks:
One is on log on, and another is on event which could be a security event for locking the workstation.
Administrative Tools --> Task Scheduler
- Create Task
--> Triggers Tab
--> New Button
--> Begin Task drop down box...
etc.

You can use the trigger event "on workstation unlock"...or "on workstation lock", in Windows 10 task scheduler.

Related

How to detect the Task Scheduler trying to terminate a program due to the "Stop if the computer switches to battery power" option

Background
I am writing a PowerShell script that runs from Windows Task Scheduler and resides in the task tray.
Problem
When you create a new task in Task Scheduler, the option Start the task only if the computer is on AC power and Stop if the computer switches to battery power are on by default.
But I don't want to stop the script when the AC adapter is plugged off. So I want to detect the Task Scheduler trying to stop the script when it switches to battery power and let the user set these options off.
Question
In a PowerShell script, is there any way to detect the Task Scheduler trying to terminate the script due to the "Stop if the computer switches to battery power" option?
You can likely detect that it is has happened, but you can probably only stop it from happening by changing the options on the scheduled task.
There should be an entry in the Task Scheduler's event log when a task is stopped due to battery power switches, and another when tasks are not started due to not being on AC power.
Since I type this on a desktop, I don't have easy access to what those event IDs would be.
I'd create a test task and see what the event IDs are, and then, if you'd like, you could create a scheduled task that triggers on either of those events.

windows 2003 doesn't open cmd as "interact with desktop" when using scheduled tasks

i have two windows servers : windows server 2003 and windows server 2008.
in windows 2008 when i start a batch script through scheduled task,
it opens a visible CMD window with my batch on it.
in windows 2003 on the other hand when i start a batch script through scheduled task,
it doesn't open a visible CMD window (interact with desktop not available?) but i can see the process of the batch running in the background.
does anyone knows how can i activate the Desktop? so i can see the CMD open
Thanks :)
so i found the solution. there were two thing i had to do:
A- check the checkbox for "Run only if logged in" in the task itself.
B- enable "Allow service to interact with desktop" on the task scheduler service.
1.)Click Start, click Control Panel, and then double-click Administrative Tools.
2.)Click Computer Management.
3.)Expand Services and Applications, and then click Services.
4.)Right-click the Task Scheduler service, and then click Properties.
5.)On the General tab, make sure that the startup type is set to automatic, and that the service status is Started. If the service is not running, click Start.
6.)On the Log On tab, make sure that the local system account is selected, and that the Allow service to interact with desktop check box has a check mark.
7.)Click OK, and then quit Computer Management.

How to check system uptime in windows 7

In windows 7 How to get the system uptime ?
How to know since how long machine is running ?
In earlier versions of windows (XP) it can be easily seen on "Local Area Connection status" by just clicking on Network icon in system tray/taskbar.
It can been seen in the task manager
Right-click on the Taskbar, and click Task Manager. You can also click CTRL+SHIFT+ESC to get to the Task Manager.
In Task Manager, select the Performance tab.
The current system uptime is shown under System.
Start task manager > performance, there is a system box that shows uptime

EC2 windows instance as dev machine, need to auto-shutdown after X period of user inactivity

I want to use an EC2 windows instance as an development environment, and want it to shutdown automatically when there is X period of user inactivity (either no remote desktop connection or idle RD connection), so as to minimize costs. Any way to do this?
You can use task scheduler inside of the windows machine to set up a trigger that will shut down the machine when it is inactive.
open the task scheduler (assuming windows 7 or 8 just type it in to
search for it in the start/search box)
on the right actions box create a task
give it a name
Run whether user is logged on or not
Run with highest privileges (shutdown requires admin rights)
Click Triggers tab
New...
Begin the task: set to on idle
click ok
click conditions tab
Check mark start the task only if the computer is idle for (your
amount of idle time)
check restart if the idle state resumes
Click the Actions Tab
New...
program = cmd.exe
add arguments = shutdown /s /f
Should be good to go after that

User's Preferred poweroff action - Windows

I have a program that takes a long time to run and is intended to run unattended. In Windows, what is the best way to determine the users preferred poweroff action.
What the power button does.
In Windows 7, the start menu logoff action (Which is Shut Down by default).
How can I determine these values on Windows XP, Windows Vista and Windows 7?
Is there an API to do this? (i.e. Shutdown, Suspend, or Hibernate according to users preferences)
If you are using managed code, there is PowerGetActiveScheme. There is an example of how to use it here: http://www.pinvoke.net/default.aspx/powrprof.powergetactivescheme

Resources