• The Old New Thing

    Why doesn't the New Folder command work in the root of a redirected drive resource in a Remote Desktop session?


    When you connect to another computer via Remote Desktop, you have the option of injecting your local drives into the remote computer, known as Device and Resource Redirection. These injected drives are available under the UNC \\tsclient\X where X is a drive letter on the local machine.

    The name TSCLIENT combines a bunch of internal technical terminology, so it makes perfect sense to the people who wrote it, but not as much to outsiders. (They may have chosen this name just to make themselves look smart.) The letters TS stand for Terminal Services, which was the former name of the technology now known as Remote Desktop. And the word client refers to the local computer, the one that is connected to the remote computer. In Terminal Services terminology, the machine you are connect from is the client, and the machine you are connecting to is the server.

    There's another level of confusion in the name of the feature. People often call these \\tsclient\X thingies Redirected Drives, which collides with the existing name for local drive letters that have been mapped to a network resource. In the user interface, these are usually called Mapped Network Drives. From the command line, you create these things via the NET USE command.

    Okay, enough with the confusing terminology. For today, we're talking about Remote Desktop Device Redirection, where the redirected device is a drive letter.

    If you open My Computer and look under Other, you'll see those drives which were injected from the local computer. Your first tip-off that there's something funny about these drives: They don't show up in the Network Location section like other mapped drives; instead they show up under the rather generic-sounding Other.

    That's because these drives aren't really drives. They are folder shortcuts, a special type of shortcut that grafts one part of the shell namespace into another. The ones created by Remote Desktop Device Redirection are shell instance objects, which is a way of creating certain types of shell extensions using just a handful of registry keys.

    Since they aren't really drives, some things that work for real drives don't work for these fake drives. And one of those things is that Explorer thinks that they don't support the New Folder command because when Explorer asks, "Do you support IStorage?" (because that's the interface that Explorer uses to create new folders), the answer is "No, you silly rabbit. I'm an Other!"

    Now, it turns out that the Terminal Services folks could've customized their Other to say, "Actually, yeah, I do support IStorage." You do this by setting the bit 0x00000008 in the Attributes value of the ShellFolder key when you registered your instance object. The Terminal Services folks forgot to set that bit, and the result is no New Folder button.

    Sorry about that.

    As a workaround, you can create your new folder by typing \\tsclient\X into the address bar. That folder is the thing that the folder shortcut is pointing to (so it's just another name for the same thing), but since it's the real thing, it correctly reports the SFGAO_STORAGE flag, and the New Folder button appears.

  • The Old New Thing

    How can I write a script that finds my top-rated photos?


    I'm not sure if I'll be able to keep it up, but I'm going to see if I can make Monday "Little Programs" day, where I solve simple problems with little programs.

    Today's little program is a script that goes through your Pictures folder and picks out your top-rated photos.

    The key step here is extracting the rating, which goes by the name System.Rating in the shell property system. The method which does the extraction is Shell­Folder­Item.Extended­Property.

    var shell = new ActiveXObject("Shell.Application");
    var picturesFolder = shell.Namespace(39); // CSIDL_MYPICTURES
    var items = picturesFolder.Items();
    items.Filter(SHCONTF_NONFOLDERS, "*.jpg");
    for (var i = 0; i < items.Count; i++) {
      var item = items.Item(i);
      if (item.ExtendedProperty("System.Rating") >= 80) {

    Wow, that was way easier than doing it in C++!

    That program searches one folder, but let's say we want to do a full recursive search. No problem. Take the code we wrote and shove it into a helper function process­Files­In­Folder, then call it as part of a recursive directory search.

    function processFilesInFolder(folder) {
      var items = folder.Items();
      var SHCONTF_NONFOLDERS = 64;
      items.Filter(SHCONTF_NONFOLDERS, "*.jpg");
      for (var i = 0; i < items.Count; i++) {
        var item = items.Item(i);
        if (item.ExtendedProperty("System.Rating") >= 80) {
    function recursiveProcessFolder(folder) {
      var items = folder.Items();
      var SHCONTF_FOLDERS = 32;
      items.Filter(SHCONTF_FOLDERS, "*");
      for (var i = 0; i < items.Count; i++) {
    var shell = new ActiveXObject("Shell.Application");
    var picturesFolder = shell.Namespace(39);

    You can use this as a jumping-off point for whatever you want to do with your top-rated pictures, like copy them to your digital photo frame.

  • The Old New Thing

    The introduction of whimsical teasing in Comic Chat


    A few months after my post on the sad demise of whimsical teasing in Comic Chat, I received a piece of email from none other than the author of Comic Chat, DJ Kurlander:

    I was the person that started the Comic Chat project in Microsoft Research and was responsible for that line, "This person is too lazy to create a profile entry."

    Not a whole lot of thought went into the default profile. In maybe the 30 seconds that I put into it, I thought that the line was moderately humorous, fit with the quirky nature of Comic Chat, and might motivate more people to create profiles. When we released version 2, MSN got the following complaint. Yes, this is verbatim (and specifically in reference to the default profile):

    I am very offended that this is type of code is allowed to leave microsoft. I am seriously considering dropping my subscription to MSN. I don't get this kind of crap from CompuServe, and I can get comparable Internet access from a local ISP. I can see that there is a serious lack of customer respect at microsoft and this is probably just the tip of the iceberg.

    MSN was pretty conservative, at least at the time, and this caused a big headache for the team. How dare we insult our customers! Did the project not have enough management overhead? Can we make things any more difficult for the small team? Yes we can! As a result, we were required to remove the message from the 2.1 release. It became "This user has no profile." at least in the version that was released on the MSN CD-ROM.

    Meanwhile, we got some advanced notice about an upcoming PC World review of the 2.0 version that had included the original message. The summary (which was emailed to us), said: "She [the reviewer] praises Microsoft for finally having a sense of humor (loves the note about being 'too lazy to have a bio' message). She claims Comic Chat is an absolute delight."

    I love the part about MS finally having a sense of humor. Well at least we were allowed to add back the message for the 2.5 release!

    Check out DJ's history of Comic Chat, which includes links to videos and other time-wasty goodness.

    Bonus chatter: DJ also has a page on Peedy the Parrot, a research project to develop a more natural user interface. Out in the product groups, we just called it that stupid parrot demo because it became tiresome from overexposure, having been used in a CES keynote and multiple company meetings.

  • The Old New Thing

    But now I'll never know which politician that alien backs for the next election


    It has been reported that everybody's favorite mock tabloid The Weekly World News is ceasing publication. Seeing as this is The Weekly World News we're talking about, I'm not sure how much of this I'm going to believe, but people seem to be taking it at face value.

    I remember seeing a WWN article clipped out and posted on the door to a geology professor's office at XYZ college. The article's title was something like "Dinosaurs alive and well—on the moon!"* It was illustrated with a drawing of happy dinosaurs wandering around a tropical lunar paradise, and the article quoted "An XYZ geology professor" as having seen the dinosaurs through a telescope. (What's a geologist doing looking at the moon through a telescope?) This was a small college, so the professor figured he must have been the one.

    Nitpicker's corner

    *This story is from memory. I may have gotten details wrong. For example, the dinosaurs may have been on Mars, not the moon. The name of the college was probably not XYZ.

  • The Old New Thing

    The Old New Thing (the book) allegedly now stocked at the Microsoft Company Store (Redmond)


    I've been informed that the Redmond branch of the Microsoft Company Store has begun stocking the dead tree edition of my book.

    "But wait, your program isn't printed by Microsoft Press; it's published by Addison-Wesley Professional. I thought the company store only stocked Microsoft Press titles."

    I'm told that this is a pilot program. (And no, I don't know what the success criteria are.)

    When I stopped by the store a few days ago, they were in the process of reorganizing the book section, so not only was my book not up, neither were any others! But it should be there "any day now."

    And remember, I'll gladly sign your book but you have to tell me what to write.

  • The Old New Thing

    Bands of Valentine minstrels roaming campus


    One of the minor Valentine's Day traditions at Microsoft is the charity fundraiser based on identifying targets and embarrassing them in front of all their colleagues. In exchange for a charitable donation to the American Heart Association (get it?) an a cappella group will travel to an office or conference room of your designation (conference room is much better, of course) and sing a sappy song to your Valentine. (Singing Valentines are also common on college campuses.)

    This can get tricky when the victim's spouse/boyfriend/girlfriend/whatever you want to call it doesn't work at Microsoft, because said potential prankster (1) needs to know about this tradition in the first place, and (2) needs to know some other Microsoft employee who can arrange the prank on their behalf.

  • The Old New Thing

    I took the Monorail to the Shadow of the Moon


    It turns out that the replacement movie wasn't any of the ones I listed. Instead, I decided to see In the Shadow of the Moon, a mid-week performance in Seattle. Since it was also a fantastically warm sunny day, traffic into Seattle was a nightmare. As the bus crawled along the highway, I had to do some mental calculations. I'm definitely going to miss my connecting bus downtown (the number 4 at 6:05pm); what's the best recovery plan? It turns out that my decision, in retrospect, was the correct one, but it was merely a lucky guess.

    I arrived downtown at 6:17pm, intending to transfer to the 3 or 4 bus to Seattle Center, home of the SIFF Cinema theater. I was just too late for the 6:15pm bus, and right at the start of the transition from peak service to off-peak service. The next bus was at 6:35pm, which would put me at Seattle Center at around 6:45. Add in time for walking from the bus stop to the theater and waiting in line to pick up my tickets, and that puts me dangerously close to missing the 7pm show.

    I briefly considered getting off at REI and taking the 8, but I didn't know how often it ran, and if I missed, I would be out in the middle of nowhere. (Turns out the 8 runs every half hour, and the next bus was the 6:35, which would have gotten me to Seattle Center at 6:45, no better than the safer plan of taking the 3 or 4.)

    Aha, the Monorail runs every ten minutes. It's 6:17. Even in the worst case, I'm still way ahead. (They don't publish a timetable. You just buy your ticket and take your chances.)

    Turns out it was the worst case. I arrived at the ticket booth just as the doors closed. But the next one arrived at 6:27, as promised, and just a few minutes later, I was at the Space Needle. A brisk walk to the SIFF Cinema theater and I had plenty of time to pick up my ticket and get in line.

    I've lived in the Seattle area for over fifteen years, and this was my first Monorail ride.

    Recapping one week of SIFF:

    2 stars out of 5 12:08 East of Bucharest: The real movie was the call-in program that addresses the question of whether there was or wasn't a revolution in the town. The first half of the movie was vignettes of a small town in Romania. They were sometimes interesting, sometimes tedious (do we really have to follow a car for two minutes as it drives through the streets of town?), and they felt like filler and "backstory" for the main story. If you showed up 45 minutes late and just caught the call-in program, you'd still get 90% of the enjoyment of the movie. One brief plot line from the first half of the movie comes back in the second; aside from that, you really didn't miss much. I give it a 2 out of 5 based on the strength of the second half.

    4 stars out of 5 Fair Play: SIFF labelled this a black comedy, and there were indeed a few black-comedic moments at the beginning, but it really would be better-described as a tense thriller. The build-up was well-done, and the twist at the end makes you mentally rewind the movie and replay it in your head so you can view the motivations of one of the characters in a different light. I give it a 4 out of 5, gaining points from the wonderful squash game, but losing points because the canyoneering trip was a bit too convenient from a storytelling point of view.

    5 stars out of 5 In the Shadow of the Moon: This was absolutely wonderful, a documentary consisting of stunning never-before-seen NASA footage from the Apollo missions and interviews with most of the surviving astronauts who have been to the moon. (Of the astronauts, all of whom are extremely well-spoken and quite funny, Michael Collins steals the show.) If this movie goes into general release, I strongly encourage every space buff to run, don't walk, to see it. The footage of the Saturn V launch brought tears to me eyes. I give it a 5 out of 5.

    There's a spectacular shot taken from the inside of a spent stage: You watch the next stage ignite and the spacecraft fade off into the distance, then as the spent stage loses attitude, the earth comes into view before the film finally runs out. During the Q&A after the movie, one person asked the director, "How did the film of that sequence survive re-entry?" The answer: The film was ejected from the spent stage and fell to earth. High-altitude planes were in pursuit with giant nets trailing out behind them. That was one insane game of "catch".

    The special surprise guest at the screening was Bill Anders, the crewmember from Apollo 8 who took the famous Earthrise photo. He quipped that Frank Borman actually took the first Earthrise photo, but Borman had the disadvantage of using the camera loaded with black-and-white film; Anders had color film in his camera.

    Bonus story #1 from Gene Cernan: "My father was alive when the Wright brothers made their first flight; he could hardly believe that I walked on the moon. My son was five years old; he thought it was no big deal."

    Bonus story #2 from Charles Duke: "After I returned, the flight doctor told me that at launch my heart rate was 144." A beat. "John's was 70." Cut to interview with John Young: "I'm old. My heart can't go any faster."


    5 stars out of 5 Would pay money to see again by myself.
    4 stars out of 5 Would see again if it were free or if seeing it with others.
    3 stars out of 5 Would recommend to others.
    2 stars out of 5 Okay, but wouldn't recommend to someone not already interested.
    1 star out of 5 Would advise against.
    0 stars out of 5 Waste of my time.

    Note: The rating scheme has been revised since this article was originally posted.

  • The Old New Thing

    How can I detect that a user's SID has changed and recover their old data?


    A customer maintained a database which recorded information per user. The information in the database is keyed by the user's SID. This works out great most of the time, but there are cases in which a user's SID can change.

    "Wait, I thought SIDs don't change."

    While it's true that SIDs don't change, it is also true that the SID associated with a user can change. Since SIDs encode the domain to which they belong, a user which moves from one domain to another within an organization, will need to be assigned a new SID.

    But wait, does that mean that the user lost access to all their stuff? After all, all their stuff was marked "Owned by X\UserName" but the user's SID is now Y\UserName.

    No, the user doesn't lose access to their stuff thanks to SID history, and if you move users around a lot, the SID history can get quite large.

    A token for a user contains not only their current identity but also all of their earlier identities. That is what permits Y\UserName to continue to access things that was marked "Owned by X\UserName": The token for Y\UserName includes an entry that says, "Oh, I used to be X\UserName."

    The customer's database can take advantage of the SID history to match up users with their former selves. Our customer was lucky in that their database recorded only users who had logged into the local machine, so that list is typically pretty small. The simplest solution for this particular customer is just to go through all the users in the database, and for each one, see if the current user has that database user in their SID history. And the easy way to do that is to make the security system do the work for you: To see if the current user has user X in their SID history, create a security descriptor that grants access only to user X, then call Access­Check to see if the current user can access it. If so, then that means that the current user was at one point in the past known as X.

    (If you have a large database where iterating over all users is impractical, you can ask for the current user's SID-History attribute and walk through the previous identities manually.)

  • The Old New Thing

    The struggle against those annoying plastic packages gains a few allies


    Some companies are switching to easy-to-open packaging. Not a moment too soon, in my opinion.

  • The Old New Thing

    Playing the hippie poetry game for four cents per line


    The party game goes by many names. Hippie poetry, Beat poetry, Dada poetry. To play, have a group of people sit in a circle and give each person a piece of paper and writing implement. To start, each person writes a single line of poetry and hands it to the person to his or her left or right. (The direction isn't important, as long as it's consistent.)

    At each round, you add one line to the growing poem, then fold over the top of the page so that only the line you added is visible. Pass the paper to the left (or right), and repeat. Popular stopping conditions are when the paper is full or when the page returns to the person who started the poem. Once the poem is complete, the paper is unfolded and everyone takes turns reading the results. They are usually quite absurd.

    That was a long and ultimately unsatisfying set-up for the fact that you can make money playing this game. And you do it via the Internet from your home. The catch: You get paid four cents per line. Oh, and the poem is about sex.

Page 378 of 447 (4,467 items) «376377378379380»