Windows: Cleaning Messy Context Menus

ShellExView and ShellMenuView

Once you install a few applications on Windows, the right-click context menu in Windows Explorer gets populated with all kinds of actions. I like to use the tools ShellMenuView and ShellExView to disable these entries. These entries in the context menu are populated from the registry and these two tools help you disable the entries that you want

Instead of a single tool, Nirsoft has created 2 tools for this job because there are 2 ways these context menu entries appear:

  • A menu item with the action and the menu item text. (For example, Play with VLC media player.)
  • A menu item populated by an Explorer shell extension of an application.

Both tools look and work similarly. You find the offending entries and disable them.

  • In ShellMenuView: You look for the offending menu item. This is easy because you just look for the offending text from the context menu item. This change should take effect immediately.
  • In ShellExView: You look for the offending application to figure out its Explorer shell extension entry and disable that. You may need to logout and login before you can see the effect of this change.

Administrator privilege is required by both these tools, since the context menu entries are resident in the HKEY_CLASSES_ROOT section of the Registry.

Tried with: ShellExView 1.70 and ShellMenuView 1.15

Advertisements

Windows XP: Cleaning uninstallable programs

Some programs just refuse to uninstall. Or they uninstall but their entry still hangs around in the Add or Remove Programs window. To remove these programs use the Windows Installer Cleanup utility. It can be downloaded here.

Windows Installer Cleanup cleans up the registry entries and the entry in Add or Remove Programs only. You will still need to manually remove the files of the application.

Windows XP: Execute Shortcut Always as Administrator

Sometimes there are applications that you wish to always execute with the credentials of another user (say an Administrator user). If you are doing this once in a while, the typical method of Shift+Right-click β†’ Run as works fine.

To make a shortcut always execute with the Run as right-click it and choose Properties. In the shortcut Properties dialog choose Advanced and then tick the Run with different credentials option. After this, whenever you invoke this shortcut it will execute with the Run as dialog.

This is useful for applications like Search Everything which need Administrator privileges to be of any use. Also, very useful for applications invoked from a launcher like Launchy where the user does not get an option to right-click and choose Run as.

ViM: Unable to open swap file

Problem

E303: Unable to open swap file for "[No Name]", recovery impossible

You might see this error while using ViM as a standard user on Windows 7. This is a result of ViM still catching up to being used as a standard user on Windows 7.

By default, ViM opens a swap file when the user starts editing an already existing file. On Windows, the swap file is a hidden dot file named the same as the opened file with a suffix of .swp. For example, editing hello.cpp will create a hidden .hello.cpp.swp. This swap file is created in the same directory as the opened file.

If the user just opened ViM and started editing into the empty editor, what happens? On Windows, a hidden swap file named _.swp is created. The above error is caused because ViM on Windows 7 tries to create this swap file in C:\Windows\System32. A standard user does not have the permissions to create files there and thus ViM throws the E303 error.

Solution

The solution would be to tell ViM to create the swap files in a temporary directory where a standard user has all the necessary permissions. A good location would be the directory pointed to by the %TEMP% environment variable. On Windows 7, this points to C:\Users\AverageJoe\AppData\Local\Temp.

The directory where ViM creates its swap files is read from the dir (or directory) variable. Setting it to %TEMP% solves the above error:

:set dir=$TEMP

Note that ViM swap file behaviour changes a bit when the dir variable is set. All swap files are created in this directory, as opposed to being created in the directories of the files being edited. And the swap filenames are not prepended with a dot. For example, editing D:\Work\hello.cpp creates a hidden swap file C:\Users\AverageJoe\AppData\Local\Temp\hello.cpp.swp

Unicode wxWidgets in a Non-Unicode World

wxWidgets can be compiled to pure Unicode mode by setting wxUSE_UNICODE to 1 in the header file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h

But what if the rest of your code that interfaces with Unicode wxWidgets is still not Unicode, but uses char and STL std::string? The changes needed at the interface are:

  • Wrap all characters and string literals passed to wxWidgets in wxT(). It converts them to Unicode. Ex: wxT("Hell World!")
  • wxWidget functions do not deal with STL std::string but with wxString. Do the conversion using wxConvUTF8, which is an instance of the wxMBConv class. MBConv stands for Multi-Byte Conversion, it helps to convert between Multi-Byte formats and Unicode. wxConvUTF8 as you can guess converts multi-byte to the UTF-8 Unicode encoding.
    Ex:

    std::string stdStr("Hell World!");
    wxString wxStr(stdStr.c_str(), wxConvUTF8);
  • When wxWidgets functions throw out a wxString, convert them back to char string using wxString::mb_str(). This returns the multi-byte representation of the internal Unicode text in wxString.

If you are curious about this fishy Multi-Byte business, check out Windows: Multi-Byte.

Windows: Multi-Byte

You run into Multi-Byte a lot when developing on Windows. For example, Visual Studio 2008 supports 2 character sets: Multi-Byte and Unicode. Notice that it does not list English or ASCII or some old comfortable 8-byte character set. Just so that we are not confused, Multi-Byte is not the same as Wide Character types and functions. Those use wchar_t, stl::wstring and their functions have a w in their name, wprintf() or std::wcout() for example.

On Windows, Multi-Byte is the old character set. It is not Unicode, which is the new (and recommended) character set. Multi-Byte code looks like old C code written to deal with English characters and strings. It uses the old C char types (char and char *), literal strings ("Hello World") and stl::string. It only differs in behavior: if Windows notices that it is running a Multi-Byte code/application on a non-English locale, the chars are interpreted and displayed according to that locale. For example, a char string of length 2 (or more) could be combined to display just one glyph in the foreign language. Hence, the name Multi-Byte for this character set, its code, libraries and applications.

PageDefrag: Does not work with Windows 7

PageDefrag is a useful utility from SysInternals, now owned by Microsoft, that can defragment the page file (C:\pagefile.sys), registry hives, log files and the hibernation file (C:\hiberfil.sys). Typically these files cannot be defragmentedΒ  while Windows is running since they are open for use. PageDefrag would schedule a defragmentation of these files during Windows boot time. This utility has been working well for me with Windows XP for many years now.

PageDefrag now seems to be useless with Windows 7. The PageDefrag dialog shows an empty list, where as it should have listed the above files. And if scheduled for boot time defragmentation, it gives a “page file not found” message. Thankfully, there are no error messages on Windows 7. Vista users have seen errors. I do not see any updates to PageDefrag since its last release in 2006 and it has been many years now since Vista was released. I guess it is RIP for PageDefrag on Vista/Windows 7 then! 😦

Update: Mark Russinovich confirms that PageDefrag works only on the x86 editions of Windows XP and Server 2003. This note can be found on page 345 of the Windows Sysinternals Administrators Reference.

Gmail: Multi-select & Progress Bars with Flashblock

A while ago Gmail introduced the nice feature of being able to multi-select attachments and to view their upload progress with progress bars. But, if you are using the Flashblock addon with Firefox this feature is not available, and Gmail will show you the traditional attachment option.

To be able to use the Gmail goodness, add mail.google.com to the Whitelist of Flashblock. You can do this in the Flashblock Options.

RockScroll

If you deal with long source files or complicated code in Visual Studio, the RockScroll add-in is something you should try. It has become indispensable since I started using it! πŸ™‚

RockScroll replaces the vertical scrollbar with a zoomed out view of the source file. As you scroll through code, a rectangular purple highlight (1 above) shows which section of the file you are currently viewing. Double-click on any word in the code and all its occurrences in the source file will be marked in purple in the editor and also shown marked in red (2 above) in the scrollbar. A great tool for code navigation!