Stupid OS/2 Tricks/Command Line Tips

From EDM2
Jump to: navigation, search

Return to OS/2 Stupid Tricks Main Page

This section covers tips and tricks which affect command line sessions.

Pasting text without the final carriage return

To paste text after a copy/mark operation without a final carriage return, hold down the Shift key while choosing Paste from the pull-down menu.

Clearing the Delete subdirectory

In order to remove the files from the Delete subdirectory of a drive to regain some drive space, type the following at a command line:

UNDELETE <drive>:\* /f /s /a

where <drive> is the letter of the drive which contains the Delete subdirectory you wish to clear.

Related subject(s):

Searching for file names

To search for a particular file name on a drive, type

DIR <drive>:\<file spec> /S


<drive> is the letter of the drive you wish to search
<file spec> is the specification of the file you are searching;

standard wild cards can be used.

Maximizing windows when opening

Command window with mouse pointer on Maximize button.

To make all command line windows open maximized, hold the Shift key while clicking on the maximize button.

Note: the above procedure causes anomalous behavior (the window opens in the upper left hand corner, then repositions itself in the middle of the screen) under the 2.11 CSD. To fix this problem, hold the Shift key while clicking on the restore button in the uppermost right hand corner of the command line window.

In some cases, you additionally may have to hold the Shift key while using the mouse to resize the window to its fullest size by dragging the bottom right corner.

Related subject(s):

Creating a scroll buffer

from Tim Sipples' FAQ

To create a small scroll-back buffer for your command line sessions, type

MODE 80,102

Related subject(s):

Using OS/2 without the Workplace Shell

To use OS/2 without loading the Workplace Shell, replace the following line in your CONFIG.SYS




where <drive> is the letter of the drive on which OS/2 is located.

Note that you can always invoke the Workplace Shell by typing PMSHELL at an OS/2 command line. It can consequently be removed by closing it from the Window List.

Related subject(s):

Enhancing speed of text scrolling

Tricks for speeding up text display.

Changing font size

Font Size dialog box with 14x8 font size highlighted.

Fonts which are 8 pixels wide generally display faster than those which are not 8 pixels wide. Choose Font Size from the pull-down menu, then choose a "x 8" type of font size.

Changing Video_ROM_Emulation

Text scrolling speed can also be enhanced using the Video_ROM_Emulation setting.

DOS Settings dialog with Video_ROM_Emulation highlighted.
  1. Select DOS Settings from either the pull-down menu of a DOS session, or from the Session page of the Settings notebook of a DOS session.
  2. Highlight Video_ROM_Emulation.
  3. Try the setting both on and off to find out if one setting results in better performance than the other.

Adding entries to your PATH

You can add entries to your PATH "on the fly" by using:

PATH %PATH%;<drive>:\<path>


<drive> is the drive on which the subdirectory you want to add is located
<path> is the path you want to add

Note: This also works for DPATH

Permanently deleting a file when Undelete is active

If you have Undelete activated (via SET DELDIR in your CONFIG.SYS), but want to delete a file or files so they can't be undeleted, use:

DEL <file(s)> /F

where <file(s)> is the file specification of the file(s) you want to delete.

Related subject(s):

Suppressing echo from *.CMD files

If you are using batch files (*.CMD) which do not have ECHO OFF statements, you can also suppress the echo by using the /Q switch:



Getting more out of your command line

contributed by Jack Tan

Supplement your command line usage by stacking commands with &&, &, ||, and ():

  • && executes the second program only if the former succeeds, e.g., RunMe.EXE && RunMeIfFormerSucceeds.EXE
  • || executes the second program if the former doesn't succeed, e.g., RunMe.EXE || RunMeIfTheFormerDidntSucceed.EXE
  • Combining && and || results in an if..then..else situation, e.g., If.EXE && Then.EXE || Else.EXE

(Else.EXE doesn't run if and only if both If.EXE and Then.EXE run successfully)

  • & runs both the first and second programs, e.g., RunMe.EXE & AndMeToo.EXE
  • () executes the instructions within the parentheses, overriding the normal order of command precedence, e.g., DETACH (FORMAT a: /once /v:"hi" && XCOPY c:\x A: /S) & UNZIP

(the commands in parentheses are operated on by DETACH, then UNZIP executes)

Checking drive status

Inspired by a code snippet by Dick Goran

You can check the status of a drive, e.g., if a floppy is inserted into a floppy drive or not with a REXX script, CHKDRIVE.CMD

The routines in CHKDRIVE.CMD can be incorporated into longer REXX scripts whenever the status of a drive needs to be ascertained.

Other REXX scripts:


Shutting down from a REXX script automatically

by David Matocha

You can shutdown your system with a countdown using SHUTDOWN.CMD combined with a scheduling utility and a automatic power-down of the system.

Related subject(s):

  • Rebooting from the command line

Using multiple arguments at the OS/2 command line

Unlike DOS, OS/2's command line allows you to use multiple arguments at the command line for the DEL and DIR commands.


 DEL <file1> <file2> <file3>
 DIR <file1> <file2> <file3>

where <file1>, <file2>, and <file3> are different filenames (with any appropriate wildcards).

Using EPM as a customized command shell

contributed by Jack Tan

EPM command shell, using the Helvetica font.

Use the Enhanced Editor (EPM) command SHELL to produce a command line with the following attributes:

  • Uses any font recognized by EPM.
  • Window sizeable to nearly any size.
  • Dynamically resizeable window.
  • Can alter text/background colors.
  • Scroll buffer spans the entire session.

Unfortunately, programs which take control of the screen (like screen-based editors) won't run.

Setting the startup directory for command line objects

contributed by Jack Tan

The 'Working Directory' entry in the settings notebook also applies to command lines, such as 'OS/2 Window' and 'DOS Full Screen.' In these cases, the working directory becomes the starting directory.

Formatting a diskette with the detach command

You can format a diskette in the background from the command line or in a batch file without user intervention with the line:

DETACH FORMAT <drive>: /ONCE /V:<label>

where <drive> is the drive of the diskette you wish to format, and <label> is the name you wish to use for the volume label.

Resizing a command line window permanently

contributed by Guy Gerard Lemieux

You can save the size of any window permanently by holding the Shift key while resizing.

Related subject(s):

Making the system "sleep"

The REXX script SLEEP.CMD will create a pause for a specified length of time.

Other REXX scripts:


Substituting REPLACE for the COPY command

The REPLACE command will only copy files of the same name from the source to the target:

REPLACE <source> <target> 

where <source> is the drive, path, and file specification of the files you want copied; and, <target> is the drive and path to which you want the files copied.

However, when REPLACE is used with certain command line switches, it becomes even more useful.

Have you ever wished you could only copy files which don't already exist on the target drive? Try:

REPLACE <source> <target> /A

Have you wanted to copy only files which have been updated? Try:

REPLACE <source> <target> /U

"Touching" a file's date and time

You can "touch," i.e., change to current date and time, a file or set of files using a form of the COPY command:

COPY <filespec> /b + ,,

where <filespec> is any valid filename or OS/2 file specification

Adding command sessions to the desktop's popup menu

Placing a percent sign in the Parameters field.

When adding OS/2 or DOS command line sessions to the desktop's popup menu, prevent the object from passing the desktop's path by putting a percent sign (%) in the Parameters field on the Program page of the command line object's Settings notebook.

Related subject(s):

Opening multiple command line sessions from the desktop menu

Desktop Settings notebook with Create New Window highlighted.

In order to be able to open multiple command line sessions from a command line object that you added to the desktop's popup menu, you must alter the desktop's settings, not those of the command line object:

  1. Open the Settings notebook for the desktop.
  2. Choose the Window tab.
  3. Under Object Open Behavior, select Create New Window.
  4. Close the Settings notebook.

Note: changing the Object Open Behavior for the desktop may have unexpected results when opening other objects from the desktop.

Related subject(s):

Creating a command line calculator

contributed by L. Kuru

EVAL.CMD is a REXX script for a simple, yet powerful command line calculator.

Several arithmetic functions are available:

  • The basic arithmetic functions:
    1. + = Addition
    2. - = Subtraction
    3. * = Multiplication
    4. / = Division
    5. ** = Exponential (must be an integer)
  • Parentheses, e.g., EVAL (2+3)**2
  • Floating point numbers, e.g., EVAL 12.345567e14*1e-50
  • Environment variables, e.g., set pi=3.1415926
set radius=3
EVAL %pi%*%radius%**2

Other REXX scripts:


Starting a DOS session with maximum free memory

contributed by Xavier Caballe

You can start a DOS session with the maximum free memory using BIGDOS.CMD.

Note: if using OS/2 2.1, you may have to change RMSIZE=640 to RMSIZE=639 in your CONFIG.SYS file in order to get this to work.

Other REXX scripts:


Using START to avoid the dreaded "clock".

contributed by Jack Tan

Use the START command in a fullscreen session to avoid the dreaded clock pointer and continue working at the command line when loading certain queue-hogging applications.

e.g, at a fullscreen OS/2 prompt:


Coloring OS/2 command line sessions

contributed by Peder Madsen

Tired of the dreaded black-and-white OS/2 command prompt? Create more colorful prompts with the PROMPT command. Try:

set prompt=$E[37;44m[$P]

which gives you white text on blue background.

Instead of 37 you can use any number between 30 and 37 to control the foreground color, and instead of 44 you can use any number between 40 and 47 to control the background color.

You can also use the PROMPT command in your CONFIG.SYS file to start each OS/2 command session with your favorite colors.

Note: ANSI must be turned on (this is the default).

Copying fullscreen text to the Clipboard

contributed by Hugo Jimenez-Vazquez

To copy fullscreen text to the OS/2 Clipboard:

  1. Open the menu for the default printer and change the status of the jobs to "Hold."
  2. Go to the OS/2 fullscreen session you wish to copy, and press the PrintScreen button on your keyboard.
  3. Go back to the OS/2 desktop and open either the Icon or Details view of the default printer.
  4. Double click on the icon of the PrintScreen job. This will place the job into the OS/2 System Editor (E.EXE).
  5. Copy the desired text from the OS/2 System Editor to the OS/2 Clipboard.
  6. Delete the job from the list of the default printer.
  7. Change the status of the default printer back to "Release."

Displaying custom DOS settings at the command line

Use asterisk as first character in "Path and File Name" box.
List of custom DOS settings (with cute cat pointer!).

contributed by Jack Tan

To list custom DOS settings (i.e., the settings which have been changed from the default) at the command line:

  1. Open the Settings notebook for the DOS program object.
  2. Put an asterisk (*) as the first character in the "Path and File Name" box on the Program page. If the filename is already an asterisk, place some text immediately after the asterisk.
  3. The icon will change to that of an OS/2 window after the change.
  4. Open the session by clicking on its icon. This should bring up an OS/2 command line window.
  5. Type "SET" (without quotes) at the command line.
  6. This should list the customized DOS settings, as well as some environmental variables.
  7. When done, remove the asterisk or extra text from the Settings notebook.
  8. If the DOS session was fullscreen initially, it may be changed to a windowed session. If so, click on the Session tab, and choose "DOS full screen."

Using PMREXX as a scrolling command window

contributed by Michael Prager

Many of us have wished for a scrolling command window, as supplied in many graphical versions of Unix. This is how to get one. At an OS/2 command line, type:


This gives a scrolling Rexx window that executes Rexx commands interactively. Since Rexx passes through all OS/2 commands, it can be used for executing OS/2 commands. Just don't forget that many OS/2 commands will need to be enclosed in quotation marks. //

Related subjects:

Switching temporarily to a different directory

contributed by Jack Tan

To switch temporarily to a different directory when at an OS/2 command line, type CMD.EXE at the command line. Switch to the directory you want, and when you are finished in that directory, simply type EXIT at the prompt. You will be back in your original directory.

Canceling print jobs from the command line

contributed by Jack Tan

You can use command line switches to cancel print jobs from the OS/2 command line:


will cancel the current print job on the default printing device.


will cancel the current print job and the rest of the print queue on the default printing device.

If you want to cancel a job on a device other than the default, add the switch


where <device> is the name of the print device (e.g., LPT2).