Tips/Support

  • The Old New Thing

    Offline mode silently prevents you from streaming media content

    • 14 Comments

    Into Windows Media Player (version 9 if you're keeping score at home), I type the URL of an MP3 file (poor man's podcast) and get the error message "The download of the specified resource has failed."

    On this dialog there two buttons: Close and Web Help. Close closes the error dialog, of course. Web Help does nothing.

    Turns out the real problem was that I was in offline mode. Go to the File menu and uncheck "Work Offline".

    So if you get the "The download of the specified resource has failed." error, check that you aren't accidentally running in offline mode.

    Working backwards, I'm guessing that the Web Help button didn't work because I was offline. Which is kind of ironic, because the only way to get help is to have already fixed your problem...

  • The Old New Thing

    How do I shut down a workstation via Remote Desktop?

    • 35 Comments

    When you are connected to a workstation via Remote Desktop, the "Turn Off Computer" option changes to "Disconnect". But what if you really want to turn off the computer, hibernate it, or put it on stand-by?

    Note: These tips work on Windows XP, but there is no guarantee that they will work in future versions of Windows.

    One way to do this is to run Task Manager and select your shutdown option from the "Shut Down" menu.

    Another trick is to click on the desktop and type Alt+F4. This will call up the shutdown dialog, where you get the usual shutdown options like "Shut down", "Shut down without installing updates", "Restart", "Stand by", and "Hibernate".

    These next two tricks are documented and will continue to work in future versions of Windows:

    If you're a command line person, you can run shutdown.exe, but that program supports only shutdown and restart; it doesn't do stand-by or hibernate. But the shutdown.exe program has a serious flaw: It requires you to have administrator privileges. If you are a limited user with shutdown privileges, the shutdown.exe program will complain. (Which means that I don't use it.)

    Finally, if your computer isn't using Fast User Switching, you can type the Ctrl+Alt+End hotkey, which is the Remote Desktop version of Ctrl+Alt+Del and consequently takes you to a dialog where you can do various system-type things, among them logging off and shutting down.

  • The Old New Thing

    Quotation marks around spaces aren't necessary in the PATH environment variable

    • 28 Comments

    The purpose of quotation marks is to allow a character that would normally be interpreted as a delimiter to be included as part of a file name. Most of the time, this delimiter is the space. The CreateProcess function uses a space to separate the program name from its arguments. Most programs separate their command line arguments with a space. But the PATH environment variable doesn't use spaces to separate directories. It uses semicolons.

    This means that if you want to add a directory with spaces in its name to the path, you don't need quotation marks since spaces mean nothing to the PATH environment variable. The quotation marks don't hurt, mind you, but they don't help either.

    On the other hand, if the directory you want to add contains a semicolon in its name, then you do need the quotation marks, because it's the semicolon that you need to protect.

  • The Old New Thing

    A look inside WinInet's index.dat file and changes in IE7 and Vista

    • 5 Comments

    My frequent bicycling buddy Ari Pernick wrote a couple of articles over on the Windows Network Development blog on the topic of the index.dat file, which appears to have gotten a bit of attention lately.

    This past weekend, I joined Ari and another friend in a ride along the Upper Loop of the annual Tour De Peaks bicycle ride. I'd never done this ride before; I tend to do the same routes over and over. This doesn't bother me like it does other people. We had originally planned to do both the Upper and Lower loops (50km each for a total of 100km), and Ari chatted with one of the ride organizers about the characteristics of the two routes in order to decide which one to take first. During the discussion, the gentleman mentioned the "food committee". That reminded me that one of Tour De Peaks' claims to fame is that it has the best food of any Northwest bicycle ride. We ended up abandoning after the first half, because both Ari and I had other things we needed to get done that weren't on our schedule when we originally signed up for the ride. But we did have the food, and it lived up to the hype. The breakfast table included fresh fruit, juice, organic coffee, muffins, and mini-bagels; lunch included pasta, potato salad, salmon quesadillas, sandwiches, pizza, brownies, and caramel popcorn. Sure beats a bottle of water and a Clif Bar. Highly recommended.

    More than once, somebody pointed out to me that the cap was missing from my water bottle. I do that on purpose. After taking a few gulps, I tuck the open bottle in my back pocket. (Bicycling shirts have pockets on the back for convenience. I keep the water there instead of in the bottle cage since most bottles not specifically designed for it are too small for the cage and end up rattling around and eventually falling out.) That way, when I want a drink of water, I can just reach back, grab a few mouthfuls, and tuck it back into my shirt pocket—I don't like drinking from those sport bottle tops. The water delivery rate is just too slow!

  • The Old New Thing

    The redirection operator can occur in the middle of the command line

    • 10 Comments

    Although the redirection operator traditionally appears at the end of a command line, there is no requirement that it do so. All of these commands are equivalent:

    echo A B>C
    echo A>C B
    echo>C A B
    >C echo A B
    

    All of them echo "A B" to the file "C".

    You can use this trick to avoid the redirection problem we discussed last time. We saw that writing

    set message=Meet at 2
    echo %message%>schedule
    

    inadvertently interprets the "2" as part of the redirection operator. One solution was to insert a space:

    echo %message% >schedule
    

    but this assumes that the space won't cause a problem. If you're in a case where that space will indeed cause a problem, you can use the trick above to move the redirection operator to a location where it won't cause any trouble:

    >schedule echo %message%
    
  • The Old New Thing

    Beware of digits before the redirection operator

    • 29 Comments

    If you want to put the string "Meet at 2" into the file "schedule", you might be tempted to use

    echo Meet at 2>schedule
    

    If you try this, however, you'll see the string "Meet at" on the screen and the "schedule" file will be blank. [Typo fixed, 10am]

    What happened?

    A digit immediately before a redirection operator modifies which stream the redirection operator applies to. If you're going to redirected an alternate output stream, it'll nearly always be the standard error stream, or stream 2. To put the error output into a file, you would write something like this:

    sort /invalidswitch 2>errorfile
    

    There is also the operator ">&" that reopens a stream as another stream. The idiom

    some-command >output 2>&1
    

    says, "Put the normal output into the file output, and then change the error output stream (2) to refer to the normal output stream (1)." The result is that both the regular output and error output end up in the output file.

    But what if you really want to put the string "Meet at 2" into the file "schedule"?

    You can insert a space between the "2" and the ">". This works for most programs since they ignore trailing spaces on their command line, but this was a trick question: The echo command is one of the few commands that actually pays attention to trailing spaces. As a result, the contents of the "schedule" file is "Meet at 2<space><cr><lf>". Maybe this is close enough for you, in which case you can skip the next paragraph.

    But what if you don't want that trailing space? For that, you can use the metacharacter escape character, the ^:

    echo Meet at ^2>schedule
    

    The last gotcha is that the pesky "2" might come from environment variable expansion.

    set message=Meet at 2
    echo %message%>schedule
    

    The trailing "2" in %message% interacts with the greater-than sign, leading to an unintended redirection. For this, you can insert a space before the greater-than sign, assuming you are in a scenario where that space is not going to cause you any problems. (And if you're in a scenario where that space will cause a problem, you can use a trick we'll look at next time.)

    Mind you, if you're going to take an environment variable whose contents you do not control and expand it onto your command line unquoted, you have much worse problems than a trailing digit messing up your file redirection. Somebody might have decided that the message should be "&format C: /y". Inserting this into the command line unquoted would yield "echo &format C: /y>schedule" which is a pretty good way to ruin somebody's day. (Well, okay, you can't format a drive with an active pagefile, but you get the idea.)

  • The Old New Thing

    Command line redirection is performed by the command line interpreter

    • 31 Comments

    The magic characters like <, >, and | in command lines like

    myprogram.exe | sort > output.txt
    

    are interpreted by the command interpreter CMD.EXE; they aren't built into the CreateProcess function. (This is obvious if you think about it. That command line created two processes; which one should CreateProcess return a handle to?)

    If you pass a command line like this to CreateProcess, it will merely run the myprogram.exe program with the command line arguments "| sort > output.txt". (The ShellExecute function behaves similarly.) If you want these characters to be interpreted as redirection operators, you need to give them to someone who will interpret those characters in the manner you intend:

    cmd.exe /C myprogram.exe | sort > output.txt
    

    Since different command line interpreters use different syntax, you have to specify which command line interpreter you want to use.

    If the command line came from the user, you probably want to use the COMSPEC variable in order to give the command to the user's command line interpreter of choice.

  • The Old New Thing

    Doing quick arithmetic from the command prompt

    • 64 Comments

    The command processor CMD.EXE comes with a mini-calculator that can perform simple arithmetic on 32-bit signed integers:

    C:\>set /a 2+2
    4
    C:\>set /a 2*(9/2)
    8
    C:\>set /a (2*9)/2
    9
    C:\>set /a "31>>2"
    7
    

    Note that we had to quote the shift operator since it would otherwise be misinterpreted as a "redirect stdout and append" operator.

    For more information, type set /? at the command prompt.

  • The Old New Thing

    The ForceAutoLogon setting doesn't do what most people think

    • 12 Comments

    The folks on the logon team wish me to remind you that the ForceAutoLogon setting does more than just log on an account automatically. They've had to deal with large numbers of people who set the key without really understanding what it does, and then getting into trouble because what they get is not what they expected.

    In addition to logging on an account automatically, the ForceAutoLogon setting also logs you back on after you log off. It is designed for machines running as kiosks or other publically-accessible scenarios where you want the kiosk account to be the only account available. Even if the user manages to fiddle with the machine and log off the kiosk user, the logon system will just log the kiosk user back on.

    As a result, setting the ForceAutoLogon setting effectively locks out all users aside from the one you are forcing. If you do this to one of your machines, you'd better have some other way of administering the machine. (Typically, this is done via remote administration.)

  • The Old New Thing

    Why do words beginning with "home" get treated as URLs?

    • 21 Comments

    Vitaly from the Suggestion Box asked (with grammatical editing),

    Could you explain why Windows starts the web browser if the file name passed to ShellExecute starts with "home".

    First thing to note is that this URL-ization happens only after the ShellExecuteEx function has tried all the other possible interpretations. If a file named "homestar" is found in the current directory or on the PATH or in the App Paths, then that file will be chosen, as you would expect. Only when the ShellExecuteEx function is about to give up does it try to "do what you mean".

    What you're seeing is autocorrection kicking in yet again. If you go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\URL\Prefixes, you can see the various autocorrection rules that ShellExecute consults when it can't figure out what you are trying to do. For example, if the thing you typed begins with "www", it will stick "http://" in front and try again. This is why you can just type "www.microsoft.com" into the Run dialog instead of having to type the cumbersome "http://www.microsoft.com".

    Most of the autocorrection rules are pretty self-evident. Something beginning with "ftp" is probably an FTP site. Something beginning with "www" is probably a web site. But why are strings beginning with "home" also treated as web sites?

    For one thing, several web sites have domains whose names begin with "home". Furthermore, some internet service providers set up their DNS so that non-fully-qualified domain names go to servers that the ISP set up specifically to provide customer services. For example, "mail" would send you to a web-based mail system, and "home" would send you to the ISP's home page.

    The use of "home" has fallen out of fashion of late, so the auto-correction rule isn't all that useful any more, but the rule stays around because it doesn't really hurt anybody, and compatibility concerns advise against removing a feature if it isn't hurting anyone and you aren't absolutely certain that nobody is still using it. (Heck, if you look at the key, you can see an entry for "gopher". Like anybody uses gopher any more.)

Page 19 of 24 (233 items) «1718192021»