• The Old New Thing

    Why do network servers sometimes show up as a Recycle Bin Location?


    A customer wanted to know why some of their users showed network servers among the locations shown in the Recycle Bin property sheet.

    Answer: Because those users are using Folder Redirection.

    In particular, if you redirect the My Documents folder, then a network Recycle Bin location is created to hold the files deleted from My Documents.

    The Recycle Bin folder in the user interface shows the union of all the recycled files in the individual Recycle Bin locations.

  • The Old New Thing

    How do I change among the three levels of play in Space Cadet Pinball?


    Many many years ago, a customer presumably was taking advantage of the unlimited support part of their support contract when they asked

    In the documentation for Space Cadet Pinball, it says...

    The game is divided into three levels of play: basic, intermediate, and advanced. The objective of all levels is to achieve the highest point total. The more advanced the level of play, the greater the point reward.

    How does one advance to the next level of play? The documentation doesn't explain.

    The level of play being described in the documentation refers not to any particular in-game option or accomplishment. It's describing three different styles of playing the same game.

    • Basic level: You try not to lose the ball.
    • Intermediate level: You earn more points by hitting the targets in the right order.
    • Advanced level: You earn even more points by completing missions.

    It's like how you can play tennis on multiple levels.

    • Basic level: Chase the ball when it is hit to you, and return it over the net.
    • Intermediate level: Anticipate where the ball will be hit, and return it to where your opponent will have difficulty reaching it.
    • Advanced level: Plan multiple-stroke attacks. Identify your opponent's weakness and adjust your style of play to take advantage of it.

    In other words, the answer is not in the game. The answer is inside you.

  • The Old New Thing

    The StartRunNoHOMEPATH policy affects whether the user's HOME path is the current directory when you use Start.Run, but make sure you read that carefully


    A customer (via the customer liaison) discovered that even though they had set the Start­Run­No­HOME­PATH policy, they found "if the user creates a Notepad file, the file is searched in the user's HOME directory, in contradiction of Start­Run­No­HOME­PATH policy,"

    I asked the liaison to confirm: "The steps you describe are rather vague. Are you saying that the problem occurs when the user opens the Run dialog and types Notepad filename.txt?"

    The customer liaison replied, "I believe the scenario is close to what you describe. The user opens the Run dialog, types Notepad, then types some text into Notepad and then does a Save As. I will confirm with the customer."

    A few days later (the customer was on leave), the customer liaison provided the exact steps:

    • Open the Start menu (Windows 7)
    • Type Notepad to search the Start menu.
    • When the Notepad program is found, click on it.
    • Type some text.
    • Perform a Save As. This operation is slow. Network traces show many accesses to the user's HOME directory.

    Okay, well, now that the steps are all carefully spelled out, it is clear what is going on. Or more accurately, it is clear what is not going on.

    The Start­Run­No­HOME­PATH policy controls the working directory when a program is run from the Start.Run dialog. Like it says in the KB article:


    If you have a home folder set and you try to run a program by clicking Start and then clicking Run, Windows searches your home folder for the program before searching the path.

    The article then goes on to describe how you can solve the problem if those are the symptoms you are trying to relieve.

    But those symptoms do not match the customer's problem.

    The customer ran the program directly from the Start menu, not by going through the Start.Run dialog. Therefore, the KB article and the Start­Run­No­HOME­PATH policy do not apply.

    Policies do what they are documented to do, not what you wish they did.

  • The Old New Thing

    There is no complete list of all notifications balloon tips in Windows


    A customer wanted a complete list of all notifications balloon tips in Windows.

    There is no such list. Each component is responsible for its own balloon tips and is not required to submit their list of balloon tips to any central authority for cataloging. In order to create such a list, somebody would have to go contact every component team and ask them for a list of all their balloon tips, and that component team would probably undertake a search of their code base looking for balloon tips. And figuring out the text of each balloon tip can be tricky since the text may be built dynamically. (And the customer didn't ask for an explanation of the conditions under which each balloon tip may appear, but that's probably going to be their follow-up question.)

    It's like publishing instructions on how to display a message on the message board, and then somebody asking the message board manufacturer, "Please send me a list of all messages that might appear on the message board." The message board manufacturer doesn't know how its customers are using the message board. They would have to go survey their customers and ask each one to build an inventory of every message that could potentially be shown.

    In other words, this customer was asking for a research project to be spun up to answer their question.

    I suspected that this was a case of the for-if antipattern being applied to custom support questions, and I asked what the customer intended to do with this information.

    It turns out that they didn't even want this list of balloon tips. They just had a couple of balloon tips they were interested in, and they wanted to know if there were settings to disable them.

    But even though that was their stated goal, they still reiterated their request for a list of balloon tips. The customer liaison asked, "Is there a possibility is getting a list of balloon tips generated by Windows itself? Even a partial list would be helpful. Can we help with this?"

    What the customer liaison can do is contact each Windows component team and ask them, "Can you give me a list of the balloon tips your component generates? Even a partial list would be helpful." I wished him luck.

    The customer liaison replied, "I passed this information to the customer and will follow up if they have any further questions." No follow-up ever appeared.

  • The Old New Thing

    How do I disable zone markers for downloaded files, so that Explorer stops being a nag about running downloaded files and just trusts me to do the right thing?


    My Little Program about manipulating the zone identifier for downloaded files appears to have struck a nerve with commenter Tess, who launched into some sort of diatribe about how Microsoft should stop being a busybody and warning users about opening files that they downloaded.

    You are welcome to disable the feature if it offends you so.

    In the Group Policy editor, go to User Configuration, Administrative Templates, Windows Components, Attachment Manager, and enable Do not preserve zone information in file attachments.

    For bonus points, you can set a bunch of other policies to make your computer even more dangerous. Here's a list of them. For example, if your goal is to create the most insecure deployment of Internet Explorer, you can set Inclusion list for moderate risk file types and Inclusion list for low risk file types both to *.*, and then on top of that, set Launching applications and unsafe files to Enabled (not secure) so that Internet Explorer never warns you about running anything.

    Welcome to 1995. Enjoy your stay.

  • The Old New Thing

    What order does the DIR command arrange files if no sort order is specified?


    If you don't specify a sort order, then the DIR command lists the files in the order that the files are returned by the Find­First­File function.

    Um, okay, but that just pushes the question to the next level: What order does Find­First­File return files?

    The order in which Find­First­File returns files in unspecified. It is left to the file system driver to return the files in whatever order it finds most convenient.

    Now we're digging into implementation details.

    For example, the classic FAT file system simply returns the names in the order they appear on disk, and when a file is created, it is merely assigned the first available slot in the directory. Slots become available when files are deleted, and if no slots are available, then a new slot is created at the end.

    Modern FAT (is that an oxymoron?) with long file names is more complicated because it needs to find a sequence of contiguous entries large enough to hold the name of the file.

    There used to be (maybe there still are) some low-level disk management utilities that would go in and manually reorder your directory entries.

    The NTFS file system internally maintains directory entries in a B-tree structure, which means that the most convenient way of enumerating the directory contents is in B-tree order, which if you cover one eye and promise not to focus too closely looks approximately alphabetical for US-English. (It's not very alphabetical for most other languages, and it falls apart once you add characters with diacritics or anything outside of the Latin alphabet, and that includes spaces and digits!)

    The ISO 9660 file system (used by CD-ROMs) requires that directory entries be lexicographical sorted by ASCII code point. Pretty much everybody has abandoned the base ISO 9660 file system and uses one of its many extensions, such as Joliet or UDF, so you have that additional wrinkle to deal with.

    If you are talking to a network file system, then the file system on the other end of the network cable could be anything at all, so who knows what its rules are (if it even has rules).

    When people ask this question, it's usually in the context of a media-playing device which plays media from a CD-ROM or USB thumb drive in the raw native file order. But they don't ask this question right out; they ask some side question that they think will solve their problem, but they don't come out and say what their problem is.

    So let's solve the problem in context: If the storage medium is a CD-ROM or an NTFS-formatted USB thumb drive, then the files will be enumerated in sort-of-alphabetical order, so you can give your files names like 000 First track.mp3, 001 Next track.mp3, and so on.

    If the storage medium is a FAT-formatted USB thumb drive, then the files will be enumerated in a complex order based on the order in which files are created and deleted and the lengths of their names. But the easy way out is simply to remove all the files from a directory then move file files into the directory in the order you want them enumerated. That way, the first available slot is the one at the end of the directory, so the file entry gets appended.

    Of course, none of this behavior is contractual. NTFS would be completely within its rights to, for example, return entries in reverse alphabetical order on odd-numbered days. Therefore, you shouldn't write a program that relies on any particular order of enumeration. (Or even that the order of enumeration is consistent between two runs!)

  • The Old New Thing

    If you cancel an operation while it's in progress, then it's not surprising that it's only half-done


    A customer (via their customer liaison) started by asking why they were seeing an unexpected access control entry in the security descriptor of an object.

    The ACEs on the parent grant access to Administrators, CREATOR OWNER, SYSTEM, and Users, but the ACEs on the child object (which should simply have been inherited from the parent) include an extra entry for Bob. How did Bob get access to the child object? When we view the details of the ACEs, it lists the Bob entry as Inherited from parent. But there is no Bob entry in the parent!

    I observed, "Probably because Bob is the CREATOR OWNER."

    Thanks for the explanation, but even if Bob is the CREATOR OWNER, how can we explain that the permission is inherited from the parent?

    The permission is inherited from the parent because the parent has specified the rights of the CREATOR OWNER, and Bob is the creator/owner. As part of the inheritance process, the rights of the CREATOR OWNER get assigned to Bob.

    Remember that CREATOR OWNER is not a real person. It is a placeholder that gets replaced with the actual creator/owner when the object is created. If Bob created the child object, then the permissions of CREATOR OWNER will be given to Bob on the child object.

    The CREATOR OWNER is not a live entry that dynamically updates to match the current creator/owner. It is a static entry that is assigned at the point of creation. Changes to the owner in the future have no effect because the identity has already been snapshotted. (I think a less confusing name would have been simply OBJECT CREATOR, since creation happens only once.)

    (Note that there is a little extra weirdness here: If the creator is a member of the Administrators group, then the CREATOR OWNER rights get assigned to the entire Administrators group instead of the specific user who created it. You can change this behavior by tweaking the Default owner for objects created by members of the Administrators group policy.)

    The customer liaison conferred with the customer, and determined that, at least in one of the cases they were studying, Bob was not the original creator.

    What actually happened was that at some point, Bob was granted access to the parent object and all its sub-objects. Later, somebody went back to the parent object and told it to revoke Bob's access to the parent object and all its sub-objects. But "If we cancel the process fast enough, then we get the strange behavior as originally described."

    Well, duh!

    You asked for Bob's access to the parent object and all its sub-objects to be revoked, so the tool you used started a recursive tree walk from the parent object looking for any objects that Bob has access to and removing them. But if you cancel the operation partway through, then that tool didn't get a chance to finish the job, and you obviously are left in a situation where Bob's access was only partially revoked.

    The customer liaison confirmed,

    Yes, that's what happened.

    It's nice of the customer liaison to confirm the diagnosis, but it still baffles me that they were confused by this in the first place.

    To me this is one of those So what did you expect type of situations. You start an operation, then partway through, you cancel it, and then you're surprised that the operation did not run to completion.

  • The Old New Thing

    How do I prevent folders like My Pictures from being recreated?


    Another converse of How do I programmatically create folders like My Pictures if they were manually deleted? and Why do folders like "My Pictures" come back after I delete them? is How do I prevent folders like My Pictures from being recreated?

    Starting in Windows 7, there is a group policy called Disable Known Folders which lets you specify a list of known folders which should be disabled.

    If somebody tries to create a known folder programmatically, the call will fail with ERROR_ACCESS_DISABLED_BY_POLICY.

    Note that this policy only blocks creation of the folder. If the folder already exists, then the policy has no effect. (You're locking the door after the horse has bolted.)

  • The Old New Thing

    Why does my setup program detect the operating system incorrectly the second time I run it?


    A customer reported that when their application called the Get­Version­Ex function, it sometimes reported incorrect values. Specifically, the logs collected from clients shows that the first time the program was run on a Windows 7 machine, the operating system was correctly reported as 6.1.7600 (Windows 7), but the second time it was run, the operating system was erroneously reported as 6.0.6000 (Windows Vista).

    This was definitely strange behavior, and upon further questioning, the customer admitted that their application was a setup program.

    The fact that it was a setup program was the missing ingredient.

    What happened is that the setup program ran, correctly detected the version as Windows 7, and then started installing its pre-requisite components. The installer for one of the pre-requisites failed, causing the entire setup to fail.

    The Program Compatibility Assistant noticed that the initial attempt to install the program failed, and it guessed (based on its internal heuristics) that the problem was that the program had an incorrect operating system version check. After the first setup failed, the Program Compatibility Assistant puts up a dialog box saying, "Hey, I think I know what went wrong. This setup program has a bad operating system version check. Do you want to give it another shot?" If the client says, "Go for it", then it will run the setup program again, but with a false operating system version.

    Unfortunately, the heuristic that the Program Compatibility Assistant used was a false positive in this case, so saying "Go for it" was the wrong answer. (Not like the client had any idea. This was a case of the computer asking the user a question they cannot answer.)

    The fix is to add a manifest to the setup program specifying whether it needs to run as administrator. It doesn't matter what the manifest says as its requirements; the fact that the manifest said anything at all means that the setup program understands the new rules introduced in Windows Vista and doesn't need the Program Compatibility Assistant's help.

    (You can read the Excluding Programs from PCA section for other ways to disable the Program Compatibility Assistant for a program.)

  • The Old New Thing

    The Visual Effects dialog box just tells you what you want to hear


    The Visual Effects dialog box has three options, "Let Windows choose what's best for my computer," "Adjust for best appearance," and "Adjust for crappiest appearance best performance." Some people have discovered the registry key where the Visual Effects dialog box remembers which radio button was most recently checked, but they found that when they programmatically manipulate the registry key, there is no effect on the actual visual settings.

    What's going on?

    What's going on is that the registry key is just there to tell you what you want to hear. It remembers which radio button you clicked, so that when you reopen the dialog box, the same radio button will be selected by default.

    The actual work of changing the setting happens when you click the OK or Apply button. The registry key is just for show.

    If you want to change a Visual Effects setting programmatically, you need to make the corresponding API call for that visual effect. For example, you might call System­Parameters­Info with the SPI_SET­NON­CLIENT­ANIMATION flag to programmatically enable or disable non-client animation.

    Note of course that by doing this you are using a global solution to a local problem. The user's visual effects preferences should be modified by the user, not by a program.

Page 4 of 27 (266 items) «23456»