cmiles – blog

Charles Miles – Tucson Hiking, Outside and Adventures, Excel, .net, Life

Hibernate – Standby: Timed LockWorkStation

There is an option for Windows to prompt for a password when the computer resumes from Standby or Hibernatation – for me this option is usually not convenient for tablet/laptop use.

Do you really care that the system suspended (after a few minutes on a ‘long-life’power setting…)? – or do you care how long it has been suspended? I tend to care about how long it has been suspended. I like my Toshiba R10 tablet to go into Standby fairly quickly when I am running on batteries (for long meetings…), if my tablet has only been suspended for a few minutes I do not want to be forced to put in a password when it resumes (especially when I need to quickly take notes or look up information!). On the other hand, if my computer has been Suspended (either Hibernate or Standby) for 45 minutes it seems 100% appropriate to be prompted for a password since it is likely I am either not around or not paying any attention to it.

I have not found a way to trigger a password prompt based on the amount of time Suspended so I wrote a small application – WARNING THIS SOFTWARE IS LARGELY UNTESTED AND VERY BETA:

Suspend Timed Lock – Application

Suspend Timed Lock – VS 2005 Project (Source)

This application sits in the system tray – it records the time that the system Suspends and on Resume looks at the number of minutes that have elapsed. If the elapsed number of minutes is greater than a number of minutes set by the user the workstation is locked.

This is not meant as a hard-core high-security solution, I am sure that there are many trivial ways to bypass it on Resume – no chance this would foil serious hackers. On the other hand, it makes casual data theft/snooping much harder (especially combined with programs like TrueCrypt), while letting the system resume without a password in situations where it is useful and convenient – the idea here is to strike a useful balance of security and convenience…

Some things I learned -
This is a really simple application. It really comes down to just two lines of code (the source is available for download to see these in context):

AddHandler SystemEvents.PowerModeChanged, AddressOf powerModeTracker
(which is an easy way to catch the Suspend event)

Declare Function LockWorkStation Lib “user32.dll” () As Boolean
(used to lock the workstation)

I thought about (and am still thinking about) implementing an option to record the time of a Montior Power Down event. I tested this idea with this code:


Private Const WM_SYSCOMMAND As System.Int32 = &H112
Private Const SC_MONITORPOWER = &HF170


    Protected Overrides Sub WndProc(ByRef m As Message)
     Debug.Print("Hit WndProc")
     If m.Msg = WM_SYSCOMMAND Then
      Debug.Print("Hit WM_SYSCOMMAND")
        If m.WParam.ToInt32 = SC_MONITORPOWER Then
         Debug.Print("Hit SC_MONITORPOWER")
        End If
      End If

     MyBase.WndProc(m)
    End Sub


The code functioned as I expected, but not when the form was hidden or minimized! When hidden or minimized the form never seems to recieve SC_MONITORPOWER. Hopefully I am missing something simple (comments giving me a clue are very welcome – this feels like something I will laugh at myself about when I know the solution), I think it would be a nice additional option.

Enjoy,
CM

Advertisement

Filed under: .net

2 Responses

  1. Aaron says:

    Awesome stuff. I’d guess that plenty of others would be interested in your solution.

    Did you know that you can set a “grace period” for the password prompt after the screen saver activates it? I found the option in the TweakUI powertoy. Not quite the same thing as you’ve got here, but useful as well.

  2. cmiles says:

    I did not know about the grace period for the screen saver password prompt – very cool! I will have to check it out, I did not spend too much time poking into the screen saver possibilities, prob. because I don’t run one on my laptop.

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

twitter -> twitterings

  • Just saw the new Resharper 6.1 Early Access version has Async CTP support listed - downloading now... 2 months ago
  • Quick post about FeedDemon/Pinboard/Save to Pinboard on Android as my choice for Google Reader Sharing http://t.co/EupWQupM 3 months ago
  • FeedDemon+Custom Sharing XML->Pinboard; NewsRob + Save to Pinboard on Android - replacing Google Reader sharing, Reader now just for sync... 3 months ago
  • Doing a few Max - http://t.co/wL8dpWk4 - tutorials - what fun, first time in a decade I have played with this... 4 months ago

RSS pinboard -> links

RSS cmiles-consuming -> posts

  • Beats, Rhymes & Life: The Travels of a Tribe Called Quest 2012 January 30
    I have no idea when I first heard a Tribe Called Quest (official site) – but it was the early 2000s before I really ‘found’ them and started listening. I would not call myself a devotee – casual fan is probably the best description – but even as a casual fan I was excited when [...]
  • Hull Zero Three, Greg Bear 2012 January 15
    I am sad to say that the first time I saw Hull Zero Three by Greg Bear (official site) on Amazon I skipped over it because of the rating – in retrospect a somewhat sad reminder to myself about the value of ratings… Thankfully on the Potpourri of Science Fiction Literature blog I came across [...]
  • Happy New Year! End of 2011 Notes… 2012 January 1
    This blog made it thru 2011! A few notes about my media/reading that I thought might be fun if this blogs lasts a few years… -Reading: I am mostly reading on my Sprint Evo 4G Android Phone via the Kindle app. While the reading experience on such a small screen is unexciting the compelling feature [...]
  • Revelation Space Universe, Alastair Reynolds 2011 December 31
    I don’t have a good enough memory or record of what I was reading in the late 1990s or early 2000s to know if this is the truth – but the way I remember it is that after a lull where I had trouble finding any science fiction I was interested in reading I came [...]
  • Sea of Glass, Barry B. Longyear 2011 December 20
    I don’t remember seeing Sea of Glass, by Barry B. Longyear, on ‘top’ science fiction lists – or stumbling across it in website recommendations; but I do remember this novel from reading it in (about…) 1990. What I remember is the brutality, terror and a dystopian future world on the brink of war. The novel [...]
  • String Quartets 2 & 3, Kevin Volans, Balanescu Quartet, Kronos Quartet 2011 December 12
    I believe I first heard Kevin Volans‘s (homepage) String Quartet No. 2 – ‘Hunting: Gathering’ in the mid-1990s on a Kronos Quartet CD. While I can not say this was immediately one of my favorite pieces, I will say that sounds from and sections of the 2nd String Quartet have stayed with me – coming [...]
  • Norwegian Wood, Haruki Murakami 2011 December 6
    Norwegian Wood was not quite what I was expecting – the Murakami novels that I have read – A Wild Sheep Chase, Hard-Boiled Wonderland and the End of the World, Dance Dance Dance, The Wind-Up Bird Chronicle, Sputnik Sweetheart, Kafka on the Shore and After Dark – all seem to me to have some place [...]
  • Looking Glass, James R Strickland 2011 November 27
    Cyberpunk! James Strickland delivers the classic elements in Looking Glass – a future United States now carved into different countries, powerful corporations, cyber space, techy jargon, decks, jacking in and action! The strength of this novel is not in offering something insightful and new – but rather in being an intelligent and fascinating rec […]
  • Await Your Reply, Dan Chaon 2011 November 21
    Dan Chaon gives us a clever plot – with several converging stories – and disturbed characters that work together to create an enjoyable and slightly uncomfortable novel. There were sections that certainly made me think about my own life and identity, but overall I was not quite completely hooked/pulled in. Rating: 3 of 5 First [...]
  • Running the Sahara 2011 November 16
    Running the Sahara – directed by James Moll – follows three athletes as they run across the Sahara Desert. They run (and sometimes walk) thru Senegal, Mauritania, Mali, Niger, Libya and Egypt. The film does a great job of showing some of the amazing landscapes that they cross – with small glimpses of the people [...]
email: charles@cmiles.info

flickr -> pictures

1202 Group Picture 2 after the Colossal Cave Run

1202 Group Picture 1 after the Colossal Cave Race

1202 Charles And Joe After the Colossal Cave Run

1201 View from about 4 miles down the trail

1201 Water coming down Sycamore Dam

1201 Life of an Outdoor Footwear Buyer

1201 Blacketts Ridge Night Run, Dana near the top

1201 Arizona Trail in the Colossal Cave Area (Rincon Valley)

1201 Richard Coming Up to hill after the turn off the AZ Trail

1112 Sunset from Pontatoc Canyon

More Photos
Follow

Get every new post delivered to your Inbox.