Friday, May 1, 2009

Utilities Roundup - Windows Support Tools

While looking through the list of commands included in Windows Support Tools I've come across some great utilities. They've also added some much needed documentation. I especially like the Overview. Two subsections on the Overview page really stand out: "Corresponding UI" and "Concepts"!

diruse.exe - Similar to du on unix/linux, a command line utility for discovering how much disk space is used by directories. More flexibile than explorer. It's maximum-size option is a treat way to find directories taking up a lot of space without having to manually traverse the directory tree.

pageheap.exe - This is also in the Windows SDK/platform SDK. It's used to track down heap corruption and/or memory leaks. Pageheap flags an application. Once flagged, it's heap allocations and deallocations go through an extra software layer to help track down heap corruption.

Heap corruption occurs when you write pass an allocation (e.g., you malloc or new 50 bytes then write more than 50 bytes, possibly corrupting memory in use by some other allocation).

It's got 2 modes; the slower but more thorough mode actually places a non-accessible block of memory after every allocation. So if you try to write past the 50 bytes you requested the application will immediately fault with an access violation.

The faster but less thorough mode surrounds your allocations with a certain pattern then checks that pattern when the application frees the allocation. If anything has changed, you know you've got heap corruption somewhere.

msizap.exe - This can be used to delete any Windows Installer information about a failed install. If an installation fails during a critical point it can be very difficult to clean up because Windows Installer won't uninstall a program it thinks is currently being uninstalled. I'd use this only if the Windows Installer Cleanup utility failed to clean up/remove an application from the Windows Installer database.

Since this app can potentially blow away the entire Windows Installer database, which might make a *lot* of programs unusable, I'd be careful with it.

setx.exe - Ever wanted a way to read the value of a registry key in a batch file without having to write a program? Setx can be used to do that. Ostensibly its purpose is to set user or system environment variables but a side effect of its ability to get values from the registry makes it useful for reading registry values in a .bat file! For example:

setx tzone -k
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation\StandardName
> t.out


echoes "Extracted value is: Eastern Standard Time" to t.out. This could easily be piped to find or findstr (instead of being redirected to t.out) for use in subsequent .bat commands.




No comments :

Post a Comment