Restart Windows and Restart All Registered Applications: shutdown -g

Sunday, August 14, 2011

The Windows Restart Manager (introduced in Windows Vista) supports gracefully shutting down and restarting applications that registered for restart with the RegisterApplicationRestart API. This functionality is used by Windows Update – thanks to the Restart Manager, when I come yawning to my desktop PC in the morning, even following a system restart, I have my Outlook, browser windows, OneNote, Visual Studio, and Messenger all lined up as they were when I went to bed. Suppose you want to initiate one of these “automagically restart everything after restart” restarts. As of a few weeks ago, I had it...

Debugging Windows Service Startup with Service Isolation

Tuesday, May 10, 2011

A year and a half ago I touched on the subject of debugging process startup, such as the startup of Windows Services, using the GFlags utility (the ImageFileExecutionOptions registry key). The general idea is to rely on the Windows loader to launch a debugger instead of the debugged process, and trace your way through the process startup code. Unfortunately, this relies on the debugged process to run in the same session as you—otherwise, you won’t be able to actually see the debugger. Starting from Windows Vista, Windows services are isolated into a separate session to which you...

What Did My Manifest Do: A Referral Was Returned from the Server

Thursday, September 2, 2010

The UAC section of an application’s manifest contains two simple settings under the <requestedExecutionLevel> element of the <requestedPrivileges> node: level – asInvoker, requireAdministrator, or highestAvailable. This setting controls whether the application will require elevation before it runs. uiAccess – true or false. This setting determines whether the application will exempt from UIPI rules introduced as part of the Windows Integrity Mechanism. If you really need the uiAccess element (and you should be really convinced that you understand why you need it before proceeding), then your application must be signed, and...
one comment

Launch a Process as Standard User from an Elevated Process

Thursday, July 9, 2009

There are many well-documented ways for launching an elevated (administrative) process from within a process that is running using standard user credentials. The cleanest way is by giving that process a manifest; if this can’t be done, the ShellExecute “runas” verb is the way to go. This is all yesterday’s news, really. However, there’s a more interesting question: how do you launch a process as the standard user, if the current process is already elevated? As you probably know, a process can’t change its elevation status – an elevated process can’t downgrade itself to a standard user, and...
one comment

Features Aren’t Magically Born

Monday, July 6, 2009

Every time I see Pavel working on his laptop, a question pops into my head: Why don’t you use the Aero theme of Windows Vista and Windows 7, and instead use something that closely resembles Windows Server 2003 – especially considering that your laptop is such a beast of a machine? Today I got my answer, well, kind of. Pavel writes: But if I don’t use Aero I don’t get thumbnail previews and other goodies. Why is that? I asked around and didn’t get a satisfying answer. I’m going to call a...
no comments

Windows API Code Pack 0.90

Sunday, June 14, 2009

Incredibly, I haven’t got a chance to blog about the Windows API Code Pack yet – even though it’s been out on MSDN Code Gallery for a couple of months already. It’s an open source .NET library which provides interop wrappers to Windows 7 (and Windows Vista) features. In fact, it would be unfair to say that these are wrappers – some of the features are organized and designed to make access from managed code significantly easier than from the native Win32/COM counterparts. By the time of this writing, there are already several extensive posts on the features...
no comments

What Should I Install – Windows Vista or Windows 7?

Tuesday, May 5, 2009

The title might imply that this is a question I’ve been pondering about, but in fact I’ve made up my mind a long time ago.  However, I’ve been asked this question multiple times by colleagues (who are usually developers) and friends (who are not necessarily developers).  Therefore, I decided to write down my answer once and for all. I currently have 6 physical machines at home running various Windows 7 builds, as well as multiple virtual machines for testing and other purposes.  All in all, I have builds of Windows 7 ranging from the M3 PDC build (6801)...
one comment

Wait Chain Traversal in Windows 7 Resource Monitor

Saturday, April 18, 2009

I blogged about wait chain traversal (WCT) a while ago – we’ve seen that it’s quite a useful tool for analyzing system-wide synchronization issues such as multi-process deadlocks, and might actually be useful for intra-process analysis as well.  What I regretted ever since is that there was no Microsoft tool for displaying WCT information, except for some rarely-cooked MSDN samples. This comes to an end with the Windows 7 Resource Monitor.  By the way, if you haven’t been introduced: Reader, Resource Monitor.  Resource Monitor, Reader.  Great, now that you’ve made the acquaintance, you can take it from here...
one comment

Enable Windows Search Indexing on Folders

Sunday, February 8, 2009

The Windows Search, introduced in Vista as part of the core operating system, is an extremely valuable tool in my pocket.  I barely ever use the start menu, ever – and why would I, if every program is just a few keys on the keyboard away? Windows Search indexing (for faster search results) is enabled by default on most of the locations you’d want it to index, but what if your app has a particular scenario in which it uses Windows Search but wants to use it to search non-indexed locations? The...
one comment

Managed Preview Handlers

Thursday, January 29, 2009

To set context, a preview handler in Windows Vista and/or Outlook 2007 is a component that provides a preview window for a specific file type (or set of file types).  For example, the default preview handler for .jpg files will display a preview of the image in the Windows Explorer or Outlook preview pane: I’ve always had the impression that writing a shell preview handler was a daunting task involving lots of native code implementing obscure COM interfaces.  I’ve also been sure that the managed interop story was very sad, for the following simple (and...
one comment