Win4Lin User's Guide

Chapter 6 -- Using Win4Lin from the command line

(User's Guide Table of Contents) (Chapter Table of Contents)
Previous Chapter - Win4Lin resource administration     Next Chapter - Mixing Windows and Linux

This chapter describes how to administer Win4Lin and configure your DOS and Windows sessions using the command-line interface.

In general, we recommend that you use the Win4Lin Setup utility in the Desktop environment for most administration tasks.

However, if you don't have the Desktop environment available, or if you want to perform some of the more advanced administration tasks that are not available through the Win4Lin Setup utility, you will find Win4Lin command-line interface useful.

This chapter only documents the usage of Win4Lin administration commands. For a complete discussion of Win4Lin configuration and administration options, see Chapter 4, ``Configuring DOS and Windows sessions'' and Chapter 5, ``Win4Lin resource administration''.

Running DOS and Windows from the Linux command line

You can start DOS and Windows sessions by using the commands dos or win from the Linux prompt.

The DISPLAY environment variable must be set to run Windows and to run DOS properly in a X window.

If the DISPLAY environment variable is not set, the DOS session runs in the xterm window with reduced functionality. Your DOS session will act like a DOS session started on a serial terminal: It will have no graphics, no color, and no DOS fonts available.

You can also start your DOS or Windows session in a window on the Desktop by using the +x option with the dos and win command to make sure the session is run in a proper X window.

Configuring DOS and Windows sessions from the Linux command line

There are two ways to configure DOS and Windows sessions using the command-line interface.

You can configure the session at the time you start it by using various configuration options with the dos and win commands.

You can also modify the default DOS and Windows configurations first by using the winconfig command with appropriate configuration options. Then, any session you start using the dos or win commands will use this modified configuration.

It is also possible to create multiple configurations from which DOS and Windows can be started, so that you can run DOS and Windows using different parameters at any time if you need to.

Using dos and win commands with configuration options

Use the dos and win commands as follows:

dos [ options ] [ dosprogram ]

win [ options ] [ winprogram ]

Options

Specifying options with dos and win commands overrides equivalent options in the personal session configurations set either by default or explicitly with the winconfig command.

+ados_device
Attaches devices to DOS or Windows environments. Most standard devices are automatically attached to your DOS or Windows environment upon startup. However, you can use this option to attach devices such as COM ports, DOS partitions, or EMS memory.


NOTE: In this version of Win4Lin, only direct attachment of I/O ports is supported, and not direct attachment of interrupts. Thus serial (COM) ports cannot be directly attached because they require interrupts. (It is expected that later versions of Win4Lin will support direct attachment of interrupts.)
dos_device is a token, which is a short name that uniquely identifies the device to the Win4Lin session. Associated with each token is a set of configuration parameters that are defined at the time the token is created (using the winadmin command or the System-Wide Win4Lin Administration option of the Win4Lin Setup utility in the Desktop environment).

The following tokens are available by default for use with the +a option:

-ados_device
Do not attach a device that is specified in your session configuration.

+b
Specifies that the MS-DOS program is stream-oriented (behaved). See ``Specifying DOS application output behavior'' in Chapter 7 for more information.

+efile[,file ...]
Interprets one or more config.sys files instead of the one specified in the session configuration. Note that there are no spaces between +e and file.

-e
Does not interpret any config.sys files.

+h
Displays help text.

+k[user:]config
Uses the personal session configuration named config. If the user option is specified, that user's config is used. (For example, to run Windows using tom's session configuration, type win +ktom:win.)

You cannot use the +kuser:config option to specify a session configuration belonging to an NIS-administered user other than yourself. See ``The winconfig command'' for more information on personal session configurations.

-l
Starts a DOS environment by booting from the floppy that is inserted in drive A.

+mn
Specifies the total standard memory in megabytes.

+pfile
Runs the DOS batch program file in place of the standard autoexec.bat file. Note that there are no spaces between +p and file.

-p
Does not execute any autoexec.bat files, not even the automatically generated ones that Win4Lin normally uses.

+r
Start the session with the initial directory at the root of your personal drive.

-r
Start the session with the initial directory set to the current Linux directory.

+sn
Sets printer timeout to n seconds and overrides any timeout setting for LPT1, LPT2 or LPT3 in the personal session configuration.

-t
For all programs passed as an argument to the commands dos and win, the default is to translate the Linux-style path separators (/) to DOS-style separators (\) and to translate Linux-style switch characters (-) to DOS-style switch characters (/). So, the command dos dir /etc -w becomes dir \etc /w before it is passed on to DOS. When the -t option is specified, this translation is disabled, and the command is passed to DOS as is.

+w
When used with a dos command, starts a DOS session using the Windows session configuration. This option is useful when you want to start DOS first, and then start Windows from that DOS session.

+x
Runs the session in its own window under X. This also requires that the DISPLAY environment variable be set appropriately as any X client program requires. (If the DISPLAY environment variable is set, then you do not have to use the "+x" option. The reason for the "+x" option is to make sure the session is run under X, and fail if DISPLAY is not set properly.)

-x
Ignore the setting of the DISPLAY environment variable, and run the session inside the window from which it is started.

+z
When running under X, this option forces the session to immediately zoom (take over the whole display) on displays were zooming is supported.

-z
When running under X, this option disables immediate zooming of the session, so that the user is prompted to zoom when necessary.

The winconfig command

You can use the winconfig utility to view or change options for your standard DOS and Windows session configurations. You can also create and save alternate configurations.

winconfig accomplishes the same thing as the Personal Win4Lin Session Configuration option of the Win4Lin Setup graphical utility.

The following forms of the winconfig utility are used for listing, setting, or deleting session configuration options:

winconfig config list [option[,option]...]
winconfig config set option=value
winconfig config delete option=value

Here, config can be dos, win, or another session configuration name. (See "Creating new configurations" for instructions on adding and removing new configurations).

To display the current setting of a given option, use the list command. For example:

winconfig win list memory

displays the current memory setting for the standard Windows session configuration (win).

To display all the configuration values for the standard DOS (dos) and Windows (win) environments, type:

winconfig dos list
winconfig win list

To set or change the value of an existing option, use the set command. For example:

winconfig win set memory=6
winconfig dos set lpt1=laser,15

To remove a device attachment option from a configuration, use the delete command. (This command works only with custom device tokens.) For example:

winconfig dos delete customdev=sound-card

removes the customdev=sound-card entry from the standard DOS session configuration. It does not remove any other customdev entries that may exist.

Setting winconfig options

To change any standard DOS or Windows session configurations, use the set command with the winconfig utility. This command takes option names as arguments. Each option is assigned a value, as follows:

winconfig config set option=value

Legal values for each option are given below. Some values are tokens. (A token is a unique name for a hardware device that is either predefined by Win4Lin or added by the system administrator. You can get a list of available tokens by using the following command: winadmin -list.)

autoexecglobal=
Specifies whether the file J:\autoexec.bat is used when you start a Win4Lin session. Values are true or false.

autoexeclocal=
Specifies whether the /autoexec.bat file on your personal drive is used when you start a Win4Lin session. Values are true or false.

autoexecprivate=
Specifies an autoexec.bat file to be used when you start a Win4Lin session. The value is the full Linux path name to the file or blank.

autofreeze=
Specifies whether your session is temporarily suspended while the input focus is switched away from your session's window to another window. Values are true or false.

autozoom=
Specifies whether or not the Win4Lin session zooms automatically. Values are true or false.

com1=
Specifies the serial port to attach for COM1 during a Win4Lin session. The value is a COM1 class token.

com2=
Specifies the serial port to attach for COM2 during a Win4Lin session. The value is a COM2 class token.

configglobal=
Specifies whether the file J:\config.sys is used when you start a Win4Lin session. Values are true or false.

configlocal=
Specifies whether the /config.sys file on your personal drive is used when you start a Win4Lin session. Values are true or false.

configprivate=
Specifies a config.sys file to use when you start a Win4Lin session. The value is the full Linux path name to the file or blank.

customdev=
Specifies a device to attach during a Win4Lin session. The value is a custom class token.

displaytype=
Specifies the display type to be used for a DOS session. The values are auto, vga, cga, mono, or herc.

dosfont=
Specifies the font size to be used for a DOS session running inside an X window. The values are auto, small, or medium.

drive=
Specifies how drive letters are mapped. This option has the following form:
   drive=driveletter,drive_name[,readonly][,exclusive]
Here, driveletter is the DOS drive letter; drive_name can be none, indicating that the drive is not mapped to anything, a DOS fixed disk in the form dosn, or a token for a virtual drive.

ems=
Specifies the amount of expanded memory to attach to a Win4Lin session. The value is a number of megabytes of expanded memory from 0 through 8.

installcolormap=
Specifies whether a private color map is used for DOS or Windows sessions running on the Desktop. Values are true or false.

lptn=
Specifies the DOS printer ports for Win4Lin sessions (LPT1, LPT2, or LPT3). The value is a printer class token, followed by a timeout value t from 5 through 3600 (or 0, which means printing never occurs as the result of a timeout), as follows:
   lpt1=token,t

maxcolors=
Value is low, medium, or high. Specifies the maximum number of colors Win4Lin allocates to a Windows session. low allocates only 20 colors. medium reserves an additional 49 colors. high reserves the original 20 colors, plus 109 more. (This option is useful only when a shared colormap is used, i.e., installcolormap is set to false, and the Desktop display has 256 colors.)

memory=
Specifies the amount of standard memory to attach to a Windows session. The value is a number of megabytes of standard memory from 1 through 64.

mouse=
Specifies the mouse definition for the Win4Lin session. The value is a mouse class token.

personaldrive=
Specifies the DOS drive letter to be used as your personal drive.

run=
Specifies an optional DOS command that Win4Lin is to run when a session starts.

scaledosgraphics=
Specifies the graphics scaling factor to be used for DOS sessions running on the Desktop in Hercules or CGA modes. Values are auto, 1, or 2.

session=
Specifies the type of Win4Lin session this configuration is used for. Values are dos, win3x, or win95.

showmenukey=
Specifies the key combination that brings the menu and status bars of Win4Lin's DOS or Windows window back into view or unfocuses the mouse when it is focused to the DOS window. You can set the key combination to any combination of <Ctrl>, <Alt>, and <Shift> keys plus another key, which you specify with the X key symbol name. When you specify more than one key, separate them with spaces and surround the combination with quotes. For example, to set the key combination to <Ctrl><Alt><Shift><F10>:

showmenukey="ctrl alt shift F10"

To set the showmenu key to be just the <Home> key:

showmenukey=Home

By default, Win4Lin defines <Shift><F12> as the key sequence.

startzoomed=
Specifies whether to zoom your session to full screen as soon as it is started from the Desktop. The value is true or false.

unzoomkey=
Specifies the key combination that unzooms. You can set the key or key sequence to any combination of <Ctrl>, <Alt>, and <Shift> keys plus another key, which you specify with the X key symbol name. When you specify more than one key, separate them with spaces and surround the combination with quotes. For example, to set the key combination to <Ctrl><Alt><Shift><F10>:

unzoomkey="ctrl alt shift F10"

To set the unzoom key to be just the <Home> key:

unzoomkey=Home

By default, Win4Lin defines <Shift><F12> as the key sequence.

windowsdir=
Specifies the subdirectory on your personal drive where Windows is installed. A typical setting is "windows".

windowsizeauto=
Specifies that Win4Lin should automatically compute the window size when a Windows 3.1 session starts. Values are true or false. When set to true, the windowswidth= and windowsheight= commands are ignored.

windowswidth=
Specifies the width of the Windows 3.1 window in pixels. The minimum width is 600. This option is ignored when the value for the windowsizeauto= command is true.

windowsheight=
Specifies the height of the Windows 3.1 window in pixels. The minimum height is 400. This option is ignored when the value for the windowsizeauto= command is true.

windowsmode=
Specifies whether your Windows 3.1 environments start in standard mode or in enhanced mode. The values are standard or enhanced.

windowspaging=
Specifies whether or not Windows 3.1 environments that run in enhanced mode should use the Virtual Memory features of Windows. Values are true or false.

xcutandpaste=
Specifies whether or not your Windows environments start with the X Cut and Paste feature turned on or off. Values are true or false.

Creating new configurations

You can create and use new configurations other than the default dos and win configurations, which can be useful if you regularly alternate between DOS or Windows environments that require different configurations.

To create a new configuration in a non-Desktop environment, use the addwinconfig command. This command simply copies an existing configuration to a new name. You can then use the winconfig command to modify it appropriately.

The syntax for addwinconfig is:

addwinconfig existing_config [copyto] new_config

For example, if you want to create a specific DOS configuration that is similar to your default DOS configuration except that it uses 2MB of expanded memory and a custom device called sound-card, follow these steps:

  1. Create a new configuration and give it a name. In this example, the new configuration is based on the default DOS configuration and is called dos-sound:

    addwinconfig dos copyto dos-sound


    NOTE: Configuration names can contain the characters A through Z (uppercase and lowercase), the numbers 0 through 9, and the hyphen (-). Although some systems allow longer names, we recommend that you limit your configuration names to no more than 10 characters.

  2. Use winconfig to change its settings:

    winconfig dos-sound set ems=2
    winconfig dos-sound set customdev=sound-card

To start a DOS session with the new configuration, use the +k option:

dos +kdos-sound

To list all of your existing configurations:

listwinconfig

To delete a configuration:

delwinconfig config


NOTE: You cannot delete the dos or win configuration.

You can also borrow a configuration file from another user by adding the user's user identification to the existing_config option of the addwinconfig command. For example, if user john has created a session configuration named goodie, and you want a copy of it, run the following command:

addwinconfig john:goodie copyto myconfig

You must have appropriate read permissions on a user's home directory before you can copy a configuration.

Win4Lin administration from the Linux command line

If you are not running in the Desktop environment, you can accomplish Win4Lin administration tasks from the Linux command line.

The following commands are available:

Using winadmin

In a non-Desktop environment, you can use the winadmin(1) command to manage device definitions. You must be logged in as root to create, modify, or delete device definitions using this command.

This section mainly describes the syntax of the winadmin command. For a complete discussion on device definition and attachment, see ``Device definition'' in Chapter 5.

Each device definition is identified by a unique token. To list the tokens currently available for attachment, use the list option, as follows:

winadmin class list

Here, class is one of the following types of tokens:

To display a definition of each class of token, type:

winadmin class printdef token

For example, to find out about tokens available for attachment as the COM1 serial port, type:

winadmin com1 list

Assume that token dcom1 was listed as one of the available tokens. To see its definition, type:

winadmin com1 printdef dcom1

Use the add option of the winadmin command to create new tokens and the update option to modify them.

For example, to create a new COM1 token, use the following command:

winadmin com1 add token:file name:"full_name"

Here, token is the token name, file name is the name of a definition file, and full_name is a more descriptive name for the token. The definition file contains all the information necessary for Win4Lin to access this particular device. See ``Tokens and full names'' and ``Definition files'' for details.

To delete tokens you have created but no longer need, use the delete option, as follows:

winadmin class delete token

For example, to delete the printer token printer1, type:

winadmin printer delete printer1

Do not use the add, update, or delete option with the ems or mouse classes.

Once you create the device definition tokens, you can attach them to a DOS or Windows session by using the +a option of the dos or win command. You can also modify your session configurations by using the winconfig command or the Win4Lin Setup graphical utility in the Desktop environment.

Note, that if you create a new virtual DOS volume token (class dosdrive), you also need to use the mkvdisk command to create the actual Linux file that will contain the new DOS volume before you can attach it to your DOS or Windows session.


CAUTION: Do not remove or modify the values of the standard tokens that come with Win4Lin. Doing so can interfere with the standard operation of Win4Lin. You may add, update, and delete only your own token definitions.

Tokens and full names

Tokens are short names used to identify device definitions.

Tokens must be unique. They can only contain the letters A-Z, the numbers 0-9, and the hyphen (-). The token names should be kept short (no more than 12 characters) to make them easy to use.

Full names (full_name) are more descriptive names for the device definitions. A full name can contain any character, including spaces. However, the entire full_name entry must be enclosed in double quotes when used in a winadmin class add command.

Definition files

A definition file contains device definition information necessary for Win4Lin to access the device from DOS and Windows sessions. You can use any Linux system text editor to create the definition file.

The definition file can be named anything and can reside anywhere. The add option of the winadmin command only reads the contents of the file in order to update its internal tables. You can delete the definition file after you run the winadmin command.

Definition files for DOS drives

Definition files for DOS drives (or volumes) contain three entries:

   attachtype=drive
   drivename=
   failureaction=

where:

attachtype=
Must always be set to the value drive.

drivename=
Specifies the full path to the Linux file name of the virtual DOS volume. Instead of a full path file name, you can use a leading H/ to indicate a file name relative to the user's home directory.

failureaction=
Can be set to abort, warn, or ignore. When this option is set to abort, any DOS or Windows session that tries to attach this volume fails to start if this volume is not available (that is, if it is in use by another process when you have used the exclusive attach option). When this option is set to warn, only a warning is issued and the session continues to start. If the option is set to ignore, all failures are silently ignored.

You should set this entry to warn unless you have special requirements that are best served with the abort or ignore option. Again, note that the failureaction setting is only used when the drive is attached with the exclusive option.

For example, the definition file for making the virtual drive /var/vdrive available for attachment contains the following entries:
   attachtype=drive
   drivename=/var/vdrive
   failureaction=warn

Definition files for virtual COM devices

Definition files for virtual attach serial ports contain four entries:

   attachtype=vpippi
   vpidevice=
   ppidevice=
   failureaction=
   irq=
   ioports=

attachtype=
must always be set to the value vpippi.

vpidevice=
must be either /dev/vcom1 for COM1 or /dev/vcom2 for COM2. (Please note that some manufacturers of multiport devices may provide their own device names for supporting Win4Lin. In that case, vpidevice= should be set to the necessary device names. Consult the multiport documentation for details.)

ppidevice=
should be set to the Linux device name of the actual serial port. Consult the device documentation for details.

failureaction=
can be set to abort, warn, or ignore. When the option is set to abort, any DOS or Windows session that tries to attach this port fails to start if this port is not available (that is, if it is in use by another process). When this option is set to warn, only a warning is issued and the session continues to start. If the option is set to ignore, all failures are silently ignored. You should set this entry to warn unless you have special requirements that are best served with the abort or ignore option.

irq=
should indicate the virtual IRQ used. COM1 uses 4, and COM2 uses 3. This is for documentation purposes only. This setting is optional.

ioports=
should indicate the virtual I/O ports used. COM1 uses 3f8-3ff, and COM2 uses 2f8-2ff. This is for documentation purposes only. This setting is optional.

For example, the definition file for making the serial port /dev/tty3a available for attachment as COM1 contains the following entries:
   attachtype=vpippi
   vpidevice=/dev/vcom1
   ppidevice=/dev/tty3a
   failureaction=warn
   irq=4
   ioports=3f8-3ff

Definition files for print spoolers

Definition files for spooler attach printers contain two entries:

   attachtype=
   printercommand=

attachtype=
must always be set to the value spooler.

printercommand=
is the Linux command that processes a print stream (for example, the lp command).
For example, the definition file for making the Linux printer laser available for use under DOS contains the following entries:
   attachtype=spooler
   printercommand=lp -dlaser


NOTE: If you are using DOS or Windows 3.1, you need to attach the newly defined printer to your session before you can use it.

If you are using Windows 95, you do not need to attach printers to your session. All available printer definitions show up in the list of available Windows 95 printers.


Definition file for direct attached devices


NOTE: In this version of Win4Lin, only direct attachment of I/O ports is supported, and not direct attachment of interrupts (IRQ) and DMA. (It is expected that later versions of Win4Lin will support attachment of these things.)

Definition files for custom direct attach devices can contain one or more of the following:

   attachtype=
   irq=
   ioports=
   memmappedio=
   dmachannel=
   physicalirq
   physicalioports
   physicalmemmappedio
   physicaldmachannel
   failureaction=
   useraccess=
The definition file can have any name and can reside anywhere. Use any Linux text editor to create the file.

attachtype=
must always be set to the value direct.

irq=
A single decimal number or series of comma-separated numbers that denote which interrupt levels are used. Values can only be 2 through 7, 9, 10, 12, or 15.

ioports=
has the following recursive definition:

X[-Y][,io_port_range]

Here, the form X specifies the I/O port address X (in hex), and the form X-Y specifies an I/O port address range, from low X (in hex) to high Y (in hex) that the device uses. As the syntax shows, single or multiple ports or ranges may be given. Values are typically in the range of 0 to 3ff (hex).

memmappedio=
has this recursive definition:

X-Y[,memory_mapped_io_range ]

Here, X and Y are two hex numbers, separated by a hyphen, denoting the range of the memory-mapped I/O. The first number is the lowest address and the second is the highest address. Each range must start on a 4K boundary and be a multiple of 4K. As the syntax shows, multiple ranges may be specified. Values are typically c0000 to effff (hex).


NOTE: When you add or remove a definition that uses memmappedio or change memmappedio in an existing definition, you must make new DOS images. See ``Making new DOS images'' in Chapter 5 for more information.

dmachannel=
is a single decimal number or a series of comma-separated decimal numbers that denote which DMA channels are used. (Note that devices that use certain DMA modes may not work.) Values may be 0, 1, 2, 3, 4, 5, 6, or 7.

physicalirq
When used, this specifies the real physical IRQ(s), and irq specifies the virtual IRQ(s) that the DOS or Windows process uses. The number of IRQ values specified must be the same in irq and physicalirq.

This line is used only when attachtype is direct and when irq is also used. It is optional.

physicalioports
When used, this specifies the real physical I/O ports, and ioports specifies the virtual ioports that the DOS or Windows process uses. The syntax of the port values for physicalioports is the same as for ioports. The ranges in ioports and physicalioports must match in size and number.

This line is used only when attachtype is direct and when ioports is also used. It is optional.

physicalmemmappedio
When used, this specifies the real physical addresses of the memory mapped I/O of the device, and memmappedio specifies the virtual address where the DOS or Windows process accesses it. The syntax of the address values is the same as for memmappedio. The ranges in memmappedio and physicalmemmappedio must match in size and number.

This line is used only when attachtype is direct and when memmappedio is also used. It is optional.

physicaldmachannel
When used, this specifies the real physical DMA channel(s) used by the device, and dmachannel specifies the virtual DMA channel(s) that the DOS or Windows process uses. The number of channels specified in dmachannel and physicaldmachannel must be the same.

This line is used only when attachtype is direct and when dmachannel is also used. It is optional.

failureaction=
can be set to abort, warn, or ignore. When the option is set to abort, any DOS or Microsoft Windows session that tries to attach this device (using +atoken or using the Win4Lin Setup window) fails to start if this device is not available (that is, if it is in use by another process). When this option is set to warn, only a warning is issued and the session continues to start. If this option is set to ignore, all failures are silently ignored. While you are setting up your token, you should set this entry to abort. Once you have a token configuration that works correctly, you should set this entry to warn unless you have special requirements that are best served with the abort or ignore option.

useraccess=
can be set to root or to nothing. When the entry is set to root, only the root user can attach this device. When this entry is removed or set to nothing, all users can attach the device. While you are setting up your token, you should set this entry to root. Once you have a token configuration that works correctly, you should set this entry to nothing so that the device becomes available to all users.

For example, consider a hypothetical adapter card for a widget device. The widget card I/O ports range from 240 to 25f, the interrupt for the card is 7, and the device requires an 8K RAM buffer with a starting address of ce000. The DMA channel field is not relevant for this device. Therefore, the definition file for this device contains the following entries:

   attachtype=direct
   irq=7
   ioports=240-25f
   memmappedio=ce000-cffff
   dmachannel=
   failureaction=abort
   useraccess=root
Be sure that the interrupt, the port ranges, and the RAM address you specify do not conflict with any already existing DOS devices (such as the mouse driver or the EMS driver). If a conflict does exist, you should change the settings on your hardware device. If you need to change the default settings for the mouse driver instead, refer to ``The mouse'' in Chapter 5.

Incorrect use of device specifications for a direct attach custom device can crash the Linux system. You should install and test the device in system maintenance mode and at a time when users are not inconvenienced if you need to reboot the system.

During this testing phase, you may have to fine tune the entries in your definition file. Instead of continuously deleting a token and adding it again, you can use the update option of the winadmin command. For example, if you want to change an entry in the definition file for widget, edit the definition file, make the desired change, and then type:

winadmin custom update widget:def-file:"Widget Adapter"


NOTE: Since this example definition specifies memmappedio, you must make new DOS images. See ``Making new DOS images'' in Chapter 5 for more information.

You can continue this testing process until you have a definition that works. Then, you should clear the useraccess= entry so others can use the device; you may also change the failureaction= entry from abort to an option appropriate to your environment.

Directly attached devices cannot be shared. As long as one process is using a directly attached device, other processes are prevented from using the device until the process controlling the device exits.

Creating virtual DOS volumes using the mkvdisk command

You can create the virtual DOS drive volume associated with the new device definition token created by the winadmin dosdrive command by issuing the following command from the proper directory:
/opt/win4lin/mkvdisk [-s] filename size

Here, filename is the name of the Linux file that will be used as the virtual volume, size is the size of the drive in kilobytes, and the -s option, when present, allocates the full size when you create the drive.

By allocating this space when you create the drive, you ensure that it is available in the future. If you omit the -s option, mkvdisk creates only a small file as a placeholder. However, this file can grow as your DOS programs use the virtual drive to store files as long as there is sufficient space on the Linux file system to accommodate the growth.

For example, to create a 5MB virtual DOS drive named mydrive.dsk in your home directory and allocate the full size at creation, type:

/opt/win4lin/mkvdisk -s mydrive.dsk 5000

Configuring running sessions from the DOS command line

The following Win4Lin commands allow you to configure your current session from the DOS prompt:

Using the printer command

You can use the Win4Lin printer command from the DOS command line to redirect DOS or Windows 3.1 printing to a Linux printer other than the default spooler doslp. (You can also put the printer command in your autoexec.bat file.) This is NOT used for configuring printing from Windows 95 or 98.

The syntax for selecting a print stream, a printer, and a Linux print command is:

printer lptn unix [prt_cmd | /r] [/x0 | x1] [/t[timeout]]

Here, n is 1, 2, or 3 and indicates whether you are using LPT1, LPT2, or LPT3.

prt_cmd specifies the Linux print command that should be used to process the DOS or Windows print requests you send to this port. If you use the /r option instead of specifying a print command, Win4Lin passes the print stream to the Linux default print process.

timeout is the number of seconds you want Win4Lin to wait without receiving print data before it passes the print stream to the Linux command. The timeout value can be in the range 5 to 3600; the default is 15. When you set /t0, print breaks (that is, when the print stream is sent to the Linux command) never occur as a result of a timeout. Instead, the print stream is sent when the DOS application requesting printing exits (/x1, which is the default setting for the printer command). When you set /x0, the print stream is not automatically sent when the DOS application exits. Setting both /x0 and /t0 causes Win4Lin to hold the print stream until you explicitly request a print break by typing:

printer lptn /p

To discard print jobs that are being held, type:

printer lptn /d


NOTE: The timeout and /x options have no meaning when you print from Windows 3.1 using the Win4Lin Network Printing driver.

For example, to direct DOS print output sent to LPT2 to a Linux printer called laser, follow these steps:

  1. Start a DOS environment if you have not already started one.

  2. Use the following printer command, from the DOS prompt, to direct print stream LPT2 to the printer named laser:

    printer lpt2 unix "lp -dlaser"

    In this command, the -d (destination) option on the lp command identifies the printer named laser.

  3. To send DOS printer output to the printer, name the DOS print stream in your DOS print command or in your DOS application. For example:

    copy letter.txt lpt2

    You can direct printer output from DOS applications to any Linux printer using the same procedures.


WARNING: Do not use print spoolers such as the DOS print command when printing to a Linux printer.

Note that the prt_cmd that you specify when you use the printer command is typically lp -d printer, where printer is the name of a Linux printer. However, prt_cmd can be any Linux command that you choose to use to process a print stream.

Tuning application execution using the merge command

The merge command allows you to tune the operation of the DOS and Windows 3.1 sessions for certain applications. (Windows 95/98 is not affected by the merge command)

Unlike the configuration options, you use the merge command to set characteristics of the DOS or Windows environment only from within DOS.

With the merge command, you can:

Handling applications that poll the keyboard

Many DOS and Windows 3.1 applications continuously poll the keyboard for keyboard input. Such applications consume system resources even when they are idle by getting into a polling loop. This reduces system performance by consuming CPU time that would otherwise be available to other processes.

Unlike standard DOS and Windows 3.1, Win4Lin automatically puts applications that continuously poll the keyboard to sleep until there is keyboard input.

Some applications may appear to be in a polling loop when they actually are not. The Win4Lin default to put these applications to sleep causes them to perform poorly in the Win4Lin environment. This situation is not common, but if you encounter it, you can disable the sleep feature.

To disable the Win4Lin default of putting applications that continuously poll the keyboard to sleep, type the following at the DOS prompt:

Win4Lin set pollsleep off

To return to the standard Win4Lin default, type:

Win4Lin set pollsleep on

Handling DOS application network transactions

From the point of view of some DOS and Windows applications, the Win4Lin file system is a network device. These applications use various DOS system calls to determine whether and how they should operate. An application may enable or disable file locking, for example, based on its tests of network status.

The four merge command options described in the following sections (drive, handle, netbios, and 5f02) have defaults that allow DOS applications to run correctly when they access the Linux file system.

Specifying local and remote drives

Some DOS and Windows 3.1 applications detect whether a DOS drive is local or remote by using the DOS interrupt 21H system call function 44H (IOCTL) code 09H (Is Logical Device Local or Remote). These applications may not operate correctly if a DOS drive is remote when the application expects it to be local or vice versa.

Win4Lin always treats your personal drive C as local; by default, it treats other Linux drives (such as D and J) as remote drives. You can change this setting for all non-personal Linux drives by typing the following command at the DOS prompt:

merge set drive local

If you always want these drives treated as local, you can insert this command in your autoexec.bat file.

To return to the Win4Lin default -- interpreting Linux drives as remote -- type:

merge set drive remote

Specifying local and remote files

Some DOS and Windows 3.1 applications detect whether a DOS file is local or remote by using the DOS interrupt 21H system call function 44H (IOCTL) code 0AH (Is Redirected Handle). These applications may not operate correctly if a DOS file is interpreted as remote when the application expects it to be local or vice versa.

Win4Lin always treats files on personal drive C as local; by default, it treats files on other Linux drives (such as D and J) as remote files.

Type the following command at the DOS prompt to configure your environment so DOS interprets files on non-personal Linux drives as local:

merge set handle local

If you always want files on these drives treated as local, you can insert this command in your autoexec.bat file.

To return to the Win4Lin default, type:

merge set handle remote

Specifying NetBIOS

Some DOS and Windows 3.1 applications specifically ask whether NetBIOS support is available before they operate properly in a network environment.

By default, Win4Lin responds yes when a DOS program asks whether NetBIOS support is available. Note that Win4Lin does not actually support NetBIOS; it only responds this way to the initial query from the application.

Although this default value does not adversely affect any tested applications, you might discover an application that does not behave as expected unless you change the default.

Type the following command at the DOS prompt to change the default so that Win4Lin responds no to inquiries about NetBIOS support:

merge set netbios off

To return to the Win4Lin default, type:

merge set netbios on

Specifying the Microsoft redirector

Some DOS and Windows 3.1 applications recognize the DOS interrupt 21H system call function 5f02 (Get Redirector List Entry) used by the Microsoft redirector.

By default, Win4Lin enables processing for this function.

Although this default value does not adversely affect any tested applications, you might discover an application that does not behave as expected unless you change the default.

Type the following command at the DOS prompt to change the default so that Win4Lin does not recognize the 5f02 function:

merge set 5f02 off

To return to the Win4Lin default, type:

merge set 5f02 on

Printing files with control characters

DOS normally opens character output devices, such as printers, in character mode. In character mode, DOS recognizes certain ASCII codes as instructions to DOS or to the output device. For example, DOS interprets the ASCII code for the Ctrl-Z (^Z) combination as an end-of-file instruction and stops processing the file at that point.

By default, Win4Lin opens character output devices, such as printers, in binary mode. In binary mode, DOS treats embedded control characters as ordinary characters and outputs them to the device just like any other character. That is, in binary mode, encountering a ^Z in a file does not cause DOS to halt printing.

To have Win4Lin open character devices in standard DOS character mode instead of binary mode, type the following at the DOS prompt:

merge set lpt_binary off

To return Win4Lin to the default of opening character devices in binary mode, type:

merge set lpt_binary on

Displaying current settings

To display the current settings for any merge command option, use the display option.

For example, to see the current setting for pollsleep, type the following at the DOS prompt:

merge display pollsleep

To see the current settings for all the merge command options, type:

merge display

Setting the DOS exit code

You can use the merge return option to set the DOS exit code to a numeric value (0 or 1) that corresponds to the state of one of the other merge options.

The merge command assigns the value 1 to the on or remote condition and the value 0 to the off or local condition.

For example, suppose you want to determine the current pollsleep setting. Type the following:

merge return pollsleep

When the current value for pollsleep is on, the merge command sets the DOS exit code to 1. When the current value for pollsleep is off, the merge command sets the DOS exit code to 0.

You can create a DOS batch file, such as errlevel.bat, to check the exit code and take appropriate action. You can include the following lines in the batch file to determine whether pollsleep is on:

   merge return pollsleep
   if errorlevel == 1 goto ISON
   echo POLLSLEEP is OFF
   goto END
   :ISON
   echo POLLSLEEP is ON
   :END

Configuring X resources

Win4Lin makes use of some X resources to configure Desktop features, mostly for color definitions. Procedures for administering X resources vary according to the X server installed on your system and are described in the documentation for your Desktop.

For a complete list of resources that Win4Lin uses, refer to the file /usr/X11R6/lib/X11/app-defaults/Win4Lin.


> > Next Chapter - Mixing Windows and Linux > >