oreilly.comSafari Books Online.Conferences.


Windows Compatibility for the Linux Desktop
Pages: 1, 2, 3

Installing Windows

After this step, exit the root account and log in as the user who will run Windows. Now you'll need your proof of ownership. If you have a non-upgrade version of Windows you need a Certificate of Authenticity. For an upgrade you need the certificate or CD from the Windows you initially installed. One of these will contain the license key Windows will ask for.

As the licensed user instead of root, run /usr/bin/win4lin-install and the installation program will recommence.

Don't start with VNET! The Windows networking system is problem-prone and isn't protected by the built-in Linux firewall. If you start with Winsock and change your mind, you can add VNET later.

The first question the installer asks is whether to use the default WinSock networking or add VNET. The latter is necessary for the Network Neighborhood feature of Windows. If you select WinSock, you'll still have access to TCP/IP, so web browsing, telnet and FTP will all still work.

Once you've made this selection, the last Win4Lin screen will appear. A Windows virtual machine will boot in a separate window.

Almost immediately, the Windows installer will request a license. Select OK and type in your key, following the instructions on your particular screen. This step will vary somewhat, depending on the Windows version and whether you have an initial or an upgrade CD.

Once the Windows installation completes and you've set the time zone, Windows will reboot. However, unlike the interminable boot of Windows on physical hardware, no sooner does the installer window close than a DOS window opens and Windows starts to reload.

You're now in a quite normal-looking Windows session, but under Linux, with the Gnome icons visible on the far left. (See Figure 3.) These icons include the Win4Lin Desktop icon that will start this Windows session from now on.

Windows session with Explorer
Figure 3. A Windows session, with Windows Explorer running

Bear in mind one thing from this point onward: always exit Windows via the Start -> Shut Down menu, not the exit button on the upper right of the X window system frame. As a guest operating system, Windows needs to shut itself down.

Configuring Drives in Windows

We need to change one thing at this point. Win4Lin has created a mydata directory in the user's home directory and pointed Window's D: drive to it. Like the Sun Java Desktop's Documents directory, it exists to supplant the My Documents directory on Windows' C: drive.

We only need one personal documents directory, so we need to remove the C:/My Documents directory that Windows created from ~/win, and the similar ~mydata directory that Win4Lin created, and then point the D: drive to the SJD Documents directory.

Windows will eventually wedge right after you or one of your users fails to install something. Before this happens, create a tar file of the user's win directory and put it with your other backups to use to restore Windows alone.

Run the Win4Lin setup program, /usr/bin/winsetup. Select Personal Session Configuration: win, then the Drives and Filesystems tab. Select the D: drive, press the Properties button and enter $HOME/Documents in the Directory field. Next, click OK, then Save, and finally Exit. When you start Windows again, you'll see the new drive letter and its contents listed as Documents.

Because you've separated programs and data, you can now back them up separately.

With a tar backup of $HOME/win, you can always return Windows to a known working state by unpacking the tar file in the $HOME/win directory. Restoring this file is a less destructive version for the "reinstall Windows" step that application help desks will tell your users to take. Because it only overwrites the basic OS, most of the other files the user has added won't be threatened.

Running Windows Programs with Unix Commands

We now have the ability to start DOS or Windows and to run programs as if we'd dual booted. However, this is not what we were trying to achieve. Instead, we should make the Windows programs run like Linux programs by selecting them from the Gnome menu or by double-clicking their data files.

Because can run both DOS and Windows under Win4Lin from the command line, it is possible to write scripts and integrate Windows programs into Gnome and Netscape just like Linux programs.

The command to run a Windows program from Linux is win. Pass it the name of the program to run and any options. For example, win c:/windows/startm~1/programs/window~1 will start Windows Explorer.

Getting Paths to Work

There are two problems with paths, both of which can interfere with running Windows programs this way. The first is that running programs from Windows can involve directories with spaces in their names. The second is that Windows wants to use drive letters in place of full pathnames.

Windows has several popular directories with spaces in them, including the Microsoft Office directory, where Project and Visio reside. If you specify one of these paths in a Unix shell script without the right quoting in place, the script will fail. This could prevent us writing a script to run Project from Linux.

The solution for this problem is to find the DOS name that corresponds to the directory you want to use. DOS does not allow spaces in names, so you can use DOS directory names in win commands. The DOS dir command will show you both the long (Windows) and short (DOS) forms of a directory name, allowing us to construct a path that will be interpreted properly in Unix.

Consider the problem of writing a script to start Microsoft Project. Project resides at C:\Program Files\Microsoft Office\Wimproj.exe, which dir identifies as C:\PROGRA~1\MICROS~2\WINPROJ. This allows us the write a project script containing the following:


If we used the command project Documents/gantt.mpp, win would find the Project binary, but wouldn't be able to interpret the path to the data file.

The path to the file to be opened doesn't have the blanks problem. Instead, it is a Unix path without a DOS drive letter, which Windows won't be able to find. The solution to this is to have a drive letter corresponding to the root, and use a full path in the script. Our script now becomes something like this:

	case "$1" in
		"'" echo "'";;
		/' echo "$1";;
		' echo `pwd`/$1
win "C:/PROGRA~1/MICROS~2/OFFICE/WINPROJ" R:`fullpath $p` "$@"

With this script in /bin/project, create an R: drive and map it to root. Run /usr/bin/winsetup once more. Select Personal Session Configuration: win, and then the Drives and Filesystems tab. Hit the Add button and enter the path /. Then click OK.

For any program that runs under DOS, we can use the same approach to write a script to run it with the same structure, except for substituting dos for win as the command name.

At this point we can write scripts to run Project, Visio, or any other DOS or Windows program from the command line.

Integrating the Programs with Gnome and Netscape

The next step is to tell Gnome and Netscape how to find the win, dos, project, and visio scripts, associate them with the file types for Project and Visio, and add the commands to the menus. Gnome and KDE predominantly use configuration files with names like win4lin.desktop to make programs available to the GUI, while mail and web programs like Netscape use mime.types and mailcap files to do the same thing. We'll work with these three file types.

Adding Win4Lin to the Shortcut Menus

Win4Lin already comes with a two files to allow its icon to appear on a Gnome desktop, an icon and a .desktop file. The first thing we'll do is set it up under Gnome. Assume for the moment that I want it in the quick-start area of the main menu, as well as in its usual place two layers down in Accessories -> Office -> Win4Lin, as shown in Figure 5.

Gnome Menus after adding Win4Lin
Figure 5. Gnome Menus after adding Win4Lin

The Win4Lin installer placed a Win4Lin.desktop file in $HOME/.gnome-desktop, so as to make a Win4Lin icon appear on the user's Gnome desktop. This does not put it in the menus for this or any other user, so we'll first move the desktop file to a safe directory and then change it to make it appear where we want in the menus. If the user doesn't want the Win4Lin icon on the desktop, she can then delete it without accidentally making it disappear from the menus.

Copy the file to the /usr/share/applications directory, then put a symlink in its place in $HOME/.gnome-desktop:

# cd /home/davecb/gnome-desktop
# mv 'Win4Lin Desktop.desktop' \
# ln -s /usr/share/applications/Win4Lin_Desktop.desktop \
	'./Win4Lin Desktop.desktop'

At this point, edit it with a text editor to add the Categories line:

[Desktop Entry]
name[en_US.ISO8859-1]=NeTraverse Win4Lin Desktop

This indicates it is found in the Applications-> Office menu, as well as the quick-start area of the main menu, as shown above.

The two X-Sun categories are peculiar to the Sun Java Desktop. The X-Sun-Supported flag indicates that the program should appear in the menus, whereas the X-Sun-Quick-Start category indicates that it should also appear in the quick-start entries at the top of the main menu. Without the X-Sun-Quick-Start indicator, it would appear in Application -> Office only.

The first two categories in the list indicate its position in the menus, under the Applications main menu, in the Office sub-menu.

The menu names used by the SJD differ slightly from the names used in the Category line. The menu/submenu names in the left column of the table below correspond to the Category= names in the right column.

Menu NameCategory Name
Java ApplicationsX-Sun-Java
System ToolsSystem

We also need to move the icon from $HOME/.merge/Win4Lin.xpm to the global icon directory, /usr/X11R6/share/icons/png/hicolor/48x48/apps, and then update the Win4Lin.desktop file to say Icon=win4lin.xpm. Gnome will find the icon by name, if it's in the default place.

Pages: 1, 2, 3

Next Pagearrow

Sponsored by: