John's Computer Journal

Thursday, May 3, 2007

Clearlooks for Windows GTK+

The Clearlooks theme engine for GTK+ is a great alternative to the wimp theme engine. Because Vista introduces some bugs into the wimp engine, I've taken a look at compiling Clearlooks for use on Windows. MinGW compiles Clearlook's code without any problems on Vista.

For those who don't have the GTK+ toolchain setup I've attached the binary compilation of Clearlooks 0.6.2 for windows. I've packed the binaries into an Installer that should put everything into the correct location. If the installer doesn't work like it should, just unzip the executable and copy all the files within the Files directory into the root of the GTK 2.0 directory.

The Installer creates a backup of the current GTK+ theme configuration, so upon uninstalling the Clearlooks theme GTK+ will switch back to the previous configuration. Any GTK+ applications will have to be restarted before theme changes take place.

Download

References

Tuesday, May 1, 2007

Single Processor Mode in Vista

Vista doesn't use boot.ini to configure the boot loader. Instead it uses bcdedit.exe and msconfig.exe To create a new boot entry that loads Vista in single processor mode follow the following steps:

  1. Open cmd in administrator mode (press the windows key, type cmd, and press ctrl+shift+enter)
  2. Type the command: bcdedit /copy {current} /d "Vista Single Processor" The command will return something like the following, but with a different number between the {}'s The entry was successfully copied to {68602c25-5097-11da-99de-000802209f1b}.
  3. Type the following command and replace the portion that says ID with the number returned from the previous command. bcdedit /displayorder {ID} /addlast
  4. Now type msconfig
  5. Click the boot tab and check mark the Make all boot settings permanent box.
  6. Select the Vista Single Processor entry and the click advanced options button.
  7. Put a check next to Number of processors, select 1, and then put a check next to Detect HAL. Click OK.
  8. Set the Timeout value to something like 3 secs. Click OK, click Yes, and Restart.
  9. Select the Vista Single Processor Entry from the boot menu to boot Vista with one processor.
References

VLC on Vista

Vista's Aero interface messes with VLC's ability to playback some videos on default settings. The video settings must be changed manually to DirectX video output. In VLC:

  1. Select the Settings -> Preferences menu.
  2. Expand the Video Section (click the plus next to video) and select Output modules
  3. Check the Advanced options box and select DirectX video output.
  4. Click Save and restart VLC.
Unfortunately, setting the output to DirectX will cause windows to disable Aero when playing back videos. The Windows GDI setting will avoid this, but won't have the hardware acceleration of DirectX and can't select menu items on DVDs. DirectX 3D will work for DVDs, but only for certain videos.

References

Wednesday, April 25, 2007

MinGW and mSYS on Vista

MinGW doesn't work well on Vista without adding some extra environment variables. The following environment variables will allow gcc to find its sub programs, the standard include paths and libraries when linking.

MinGW Variables

GCC_EXEC_PREFIX=c:\mingw
PATH=%GCC_EXEC_PREFIX%\libexec\gcc\mingw32\3.4.2;%PATH%
PATH=c:\mingw\bin;%PATH%
MinGW must be installed to the root directory. For example c:\tools\mingw will not work. It must be c:\mingw.

mSYS Variables

PATH=c:\msys\1.0\bin;%PATH%
HOME=%HOMEPATH%
Vista will force a User Access Control (UAC) message to elevate privileges whenever it detects a program with the words setup, install, or patch in the filename or description. However when a program is run from the command line, Vista will not bring up the (UAC) message and just deny access to the executable. To get around the problem make sure to work with elevated privileges when performing a make install or when patching.

Refferences

Monday, April 23, 2007

Simple Batch script Program Installer

The following batch script will install a program into the Program Files directory on the computer. The batch script will create and register an uninstaller, and create a shortcut in the Start Menu. To uninstall the program simply click the program's entry in the "Add / Remove Programs" control panel.

Usage

Pass the script the name of a directory containing an executable. The script assumes the directory and executable have similar names. If the names don't match, rename either the directory or the executable.

Requirements

The batch script will run on any Windows operating system. I have tested the batch script on Vista. Windows XP and 2000 should also work. To run the script on Windows 9x modify the startMenu variable to point to Windows 9x's start menu location.

Why?

Some programs don't have installers. Sometimes I'll put a program someplace and forget I have it because it doesn't show up in the start menu or in the "Add / Remove Programs" control panel.

Download

quickInstall.bat

Sunday, April 22, 2007

sudo for Vista's User Access Control (UAC)

By setting a SHELLEXECUTEINFO's lpVerb value to "runas" a call to ShellExecuteEx will cause the UAC to elevate the run privileges for a given program. The concept can be implemented into a simple program so that a behavior similar to linux's sudo command can be achieved.

Methods of Implementation

The ShellExecuteEx runas method can be implemented by any method that interfaces with the ShellExecuteEx API. The code provided below for download was written using c++. Within a visual basic script the ShellExecute function of the Shell.Application object can be used to invoke runas.

The command line tool `runas' provides similar functionality. However, the `runas' command is different enough that it can be confusing for users to use in Vista. The obvious difference is the command line vs. the graphical interface. Other differences include the inability for the `runas' command to accept empty passwords and recognize when the user already has elevated permissions.

Issues

Directory Change

When the runas verb is passed to ShellExecuteEx the current directory always gets reset to the %systemroot%/system32 directory. The lpDirectory variable has no effect. Therefore, to maintain the correct directory the directory must become part of the command that ShellExecuteEx runs. By wrapping the command to execute using runas within a %comspec% /c cd /d "directory" start /d "directory" call the correct directory is used when the command or file is executed.

User Context

The ShellExecuteEx runas method suffers from the same user context problems that haunt the command line tool `runas'. The context switch can cause problems for programs that access user specific areas and variables such as the username, home directory, desktop, or registry. For example, if an installation program is launched through `runas' by a non-administrative user an option such as "create desktop shortcut for local user" will create the shortcut on the administrators desktop NOT the desktop of the user that initialized the installation through the runas command.

There is a workaround to the context problem that would require the user to provide an administrative username and password and then provide their own non-administrative username and password. Aaron Margosis introduced the concept in his "Non-Admin" WebLog where he introduced his MakeMeAdmin batch script.

Download

References

TweakUAC has a package of functions to handle UAC events. The VistaTools.cxx package clued me into setting the lpVerb to "runas".

Friday, April 20, 2007

Nested Environment Variables

The following workaround example shows how to nest environment variables inside of each other in a batch file. The nested variables can be used for specifying sub-string indices or replacements dynamically during runtime.

For example to remove the current directory from the path environment variable:

set path=%PATH:%CD%=%

does not work. However, the following code:

for /f "delims=" %%i in ('echo %%PATH:%CD%^=%%') do set path=%%i

will work fine.

References