How to programmatically fight with WPS:Lost/broken desktop or broken Templates or Startup

<< PMWP entries in POPUPLOG.OS2 -- Index -- URL objects >>

Where to begin... How about a warning? The best way to "lose" your Desktop (without suffering any real damage) is to access one installation's Desktop from another setup on the same machine. E.g. I installed FP14 on my alternate setup, then later started looking at its Desktop from my FP7 setup. When I rebooted to the FP14 system, all I got was a command window on an empty Desktop.

First step: edit config.sys and add this line, then reboot. SET DESKTOP=C:\DESKTOP (see Order of DESKTOP and ). If everything comes back as it should be, run the following code call ReportRC(SysSetObjectData("C:\DESKTOP","OBJECTID="))

(put this in Boilerspace template); then "rem-out" the line in config.sys until the next time it's needed. You need to run the REXX script or else many installers will be unable to create Desktop objects; you'll want to disable the config.sys entry so you'll know when a problem has occurred. These two steps will solve most lost Desktop problems.

After rebooting, if your Desktop returns and all of the folders and files are present but all of the program objects, shadows, and miscellanea are missing, then os2sys.ini is probably corrupted. If you have pgm objects or shadows that point at files on other disks, see if they're still good in order to gauge the extent of the damage. Also, pop up the Desktop menu and select 'System Setup'. Does the folder open?

At this point, you have several options (see also Script to recreate all or some lost objects). The best would be to restore a *recent* archive of your Desktop from the Alt-F1 boot screen. If you were able to open System Setup from the Desktop menu, you may instead want to restore recent backups of os2.ini & os2sys.ini, such as those made by checkini. You can either reboot to a command line and copy them over, or you can edit config.sys and (temporarily) change SET SYSTEM_INI= and SET USER_INI= to point to them, then reboot. If you choose the latter option, you can copy & rename the files and reedit config.sys after you're satisfied with the results.

Lacking recent backups, you still have some options. First run checkini in diagnostic mode (i.e. *without* the "/C" option). If you weren't able to open System Setup from the Desktop menu, see if it offers to assign the object ID  to the System Setup folder (and makes similar offers for other standard folders as well). This will determine whether you'll be forced to run MAKEINI. Also, see if it finds valid objects assigned to "missing" folders. If so, you should be able to recover them when you run it again in "fixit" mode.

If opening System Setup wasn't a problem, or if checkini offered to fix it, you can rerun checkini with "/C" to recover as much as possible. Avoid letting it delete anything and skip the final file handles check altogether. After a reboot, see how things look. You may have to drag a lot of recovered objects back to their proper folders, and some things may still be screwed up. By not deleting anything on the first run, you may have invalid program objects but at least you'll know what you used to have and what needs fixing. When things are back to normal, then run checkini again and let it do all the cleanup still required.

My repeated mention of opening System Setup from the Desktop menu is simply a quick way to see if the standard folders have the object IDs they need for a properly functioning system. If they don't, then you probably have other problems as well that need fixing. For this you'll want to run a *non-destructive* MAKEINI with this command line (after making a backup): MAKEINI OS2.INI INI.RC Before doing so, you may want to customize INI.RC and eliminate or comment-out things you don't want (e.g. all those tired URL objects, or, at the end of the file, the 3 lines that will reset your display to VGA).

When you reboot, the WPS will create a new Desktop with all new folders and objects, and will rename your current (defective) one as Previous Desktop. After another reboot (just in case), run checkini and see what it can recover (in this case, let it remove any duplicate object IDs it finds from the previous Desktop's objects). Chances are that you'll have to drag a lot of things from the old desktop to the new.

When this long ordeal is finally over, you can delete the previous or temporary Desktop folder(s). Because they have the NODELETE style, you'll have to get rid of this before 'Delete' appears on their menus. One way is to plug this into the Boilerspace template): rc = SysSetObjectData( "C:\PREVIOUS DESKTOP","NODELETE=NO") Except for a few details here and there, AFAIK, that about covers it. Did I answer your question, Barbara?

BTW... since I haven't plugged DragText yet, I should mention that it can be a handy adjunct when dealing with these problems, e.g., validating required object IDs (as found in INI.RC), accessing & examining objects as checkini finds them (via the numeric object handles it displays for each), etc. See DragText.

Order of DESKTOP and 
If D:\DESKTOP does exist and your config.sys says SET DESKTOP=D:\DESKTOP, the WPS will attempt to use it. If that directory doesn't exist, of course you're going to have problems.

If this line is not in config.sys, the WPS will try to locate the Desktop using os2.ini info. If that info is missing, you'll have your current problem. Use the following REXX script to restore the info to os2.ini. Just be sure that it points to your current, *valid* Desktop path (and don't forget to delete the "set desktop=" line in config.sys).

Details on lost desktops
This problem comes in two flavours: "plain vanilla" and "rocky road".

First, restore the backup ini files (even though they didn't work last time). In config.sys, add "SET DESKTOP=E:\DESKTOP", then reboot. This will point PM at your original Desktop directory. If all your program objects, shadows, and other non-filesystem objects reappear, you had the "plain vanilla" problem. All you need to do now is run the REXX script below.

OTOH, if only files and folders reappear and/or you get unexpected objects in unexpected places, you've got "rocky road". In this case, consider yourself lucky if you can recover any of your old setup. If you don't already have it, get wptool19.zip so you can run checkini.exe. The first time you run it, you may want to omit the "/C" command line parameter so that it only reports errors and doesn't try to fix them.

The first time you have it try to fix things, your primary goal is to have it recover objects that it says are located in non-existent directories. Say 'no' to most offers to fix other problems. After a reboot, your Desktop will be filled with folders full of found objects. Retrieve and fix your own objects but skip system-supplied ones. Things will be so messed up that you'd do well to run a nondestructive MAKEINI to recreate your System Setup, Startup, etc. folders and the objects therein (see Startup folder and ObjectID, Hanging template folder, Restoring System Setup or Templates, ini.rc and SysCreateObject, Script to recreate all or some lost objects). After that's done (and you've rebooted yet again), run checkini again to clean up the mess that remains.

FYI... the "plain vanilla" problem is common and easy to fix: the Desktop folder's Object ID (i.e. ) has disappeared, so the WPS can't find it. The REXX line in Lost/broken desktop or broken Templates or Startup restores it. The "rocky road" problem is semi-catastrophic: the file handles table in os2sys.ini got lost/corrupted and the system assigned all new handles to the files and folders on your E: drive. The WPS uses these handles to associate abstract (i.e. non- filesystem) objects with particular folders. Now that the folders' handles have changed, your abstract objects are no longer associated with any folder, so they're in limbo. Checkini will fix this by associating these objects with new folders it creates.

Startup folder and ObjectID
To actually do anything, your Startup folder must be of class WPStartup and have the object ID "".

For future reference... Chances are that this Startup folder had lost either its ObjectID ("") or its .CLASSINFO extended attribute. ObjectID is easy to fix: use SysSetObjectData in a REXX script to restore it. Losing the EA that tells the WPS that this is a Startup folder renders it useless, so you have to create a new Startup folder. If you search \os2\ini.rc, you'll find any entry for this folder that contains all the parameters you'll need to recreate it using SysCreateObject. Note that the parms are *not* listed in the order that SysCreateObject requires, so you'll have to do some transposition. See ini.rc and SysCreateObject, Script to recreate all or some lost objects.

Hanging template folder
More than likely, there's some invalid object in there which is causing the hang - perhaps a template for some object class you've deregistered. Here's a list of steps you can take to fix things, starting with the most benign:

No comment necessary :-)
 * run checkini.

I've seen invalid entries or references to nonexistent classes in here cause stuff to disappear
 * delete the Templates Folder's .ICONPOS EA

This provides the list of options on the Create Another submenu; it will be rebuilt as the WPS rediscovers your templates.
 * delete "PM_Workplace:Templates" from os2.ini

Obviously not an option here since you can't access them. It's worth noting that any class that provides a template will recreate it on demand - only the ones that are customized or "variations on a theme" will be lost. If you do this, be sure to delete "PM_Workplace:Templates" from os2.ini afterwards.
 * delete the contents of Templates


 * delete the Templates Folder, then recreate it
 * Before doing so, use your file manager to move any customized file templates to another directory. For example, Lotus WordPro has a subfolder in there filled with specialized templates that will be lost otherwise. The best place to put them is a folder deep in your directory tree where neither it nor it parent is likely to be accessed.
 * After saving what you want, delete the remaining files and directories, then delete the Templates folder itself. I don't know if you'll be able to do this while the WPS is running. Regardless, avoid accessing both Templates and whatever folder it's in during the session you do all this.
 * Delete "PM_Workplace:Templates" from os2.ini.
 * Kill the WPS or reboot, then run this script to recreate Templates (the SysCreateObject call should all be on one line):

/* script to recreate the TEMPLATEs folder */ call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' call SysLoadFuncs rc = SysCreateObject( "WPTemplates", "Templates", "",     "HELPPANEL=15680;NODELETE=YES;OBJECTID=", "UPDATE") (compare with Restoring System Setup or Templates).


 * Finally, open your new Templates folder. There should be a lot of activity as the WPS recreates all of the standard templates. Return any templates you saved *and* open every folder you know contains templates (this will repopulate "PM_Workplace:Templates" and your Create Another menus).

A final note: if you've installed Feature Installer, you probably have a template labelled Data File:1 that shows a hammer and screwdriver. Then see Data File:1 and NODELETE.

You can put this to good use if you want to delete undeletable templates. Open this file in a text editor (you can Shift-dragitsicontoyoureditor ' sicon ,thenShift - dropit ) .Addthissingleline( withoutquotes ) ,thensavethefile: "NODELETE=NO" Whenever you need to delete an undeleteable template, just drop it on this template. The dropped object will now have a Delete entry on its popup menu and can be deleted in any of the usual ways.

can't choose properties of Desktop
When I press RMB on the desktop I can't choose properties. Does anyone know the reason? I used to be able to choose it. I have installed FP1 and FP3 on my Warp 4.

When you say you "can't choose properties", do you mean: ''I'm sorry... The properties entry is missing from the menu.''
 * that entry is missing from the menu?
 * the entry is present but disabled (greyed-out)?
 * you can select Properties but nothing happens?

OK... Have you recently installed any WPS "enhancements", or more likely, any WPS security add-ons that are designed to keep users from changing things? If not, try the following REXX script. Either drop your Desktop folder icon on it, or run it from the command line supplying the path of your Desktop folder as an argument (i.e. settings c:\desktop ).

Put this in Boilerspace template: call ReportRC(SysSetObjectData(object,"NOSETTINGS=NO"))

Restoring System Setup or Templates
The desktop pop-up menu which displays the System Setup line to show the particular folder is still there, but doesn't bring up the folder. System setup itself is in the OS/2 system folder and is still there.

Can anyone tell me how to "re-activate" the System Setup line in the pop up menu?

I hope I'm not too late and you haven't done a reinstall... Try this (Put this in Boilerspace template): call ReportRC(SysSetObjectData("F:\Desktop\OS!2 System\System Setup","OBJECTID=")) Similarly for templates: call ReportRC(SysSetObjectData("F:\Desktop\OS!2 System\Templates","OBJECTID="))

ini.rc and SysCreateObject
Whenever you damge or destroy a system-supplied object, go to \os2\ini.rc, find the entry for the object, then reformat the parameters for use with the REXX SysCreateObject command. In this case, the line from ini.rc is: "PM_InstallObject" "Drives;WPDrives;;RELOCATE" "ALWAYSSORT=YES;NODELETE=YES;DEFAULTVIEW=ICON;OBJECTID=" Below is a REXX script that uses these parms. Note that neither "PM_InstallObject" nor "RELOCATE" are applicable in a REXX script. OTOH, the "REPLACE" parameter included below is REXX-specific; it is documented in your online REXX ref. (N.B. this is for Warp v4; for v3, change  to )

Put this in Boilerspace template, SysCreateObject call should be all on the same line: /* REXX script to recreate the Drives folder*/ call ReportRC(SysCreateObject("WPDrives", "Drives", "", "ALWAYSSORT=YES;NODELETE=YES;DEFAULTVIEW=ICON;OBJECTID=<WP_DRIVES>", "REPLACE"))

Script to recreate all or some lost objects
/* ReCreate.CMD - restore lost desktop objects             */ /* by Greg Czaja - July 29, 1992                           */ /*              - April 9, 1993  ver.2                     */ /*                handle 2.1-style INI.RC                  */ /* the July 1992 REXXUTIL version is required for 2.0 GA   */ /* (look for REXX20 in Lib 17 in OS2SUPPORT)               */ /* no additional requirements for GA+SP or 2.1             */ Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs' Call SysLoadFuncs; SysBootDrive=Filespec('Drive',Value('SYSTEM_INI',,'OS2ENVIRONMENT')); file_name=SysBootDrive||'\OS2\INI.RC'; Say "The program will list all single standard objects from your desktop" Say "Reply Y(es) if you want recreate the listed object - E(nd) to end the program" Say "N(o) is the default if you press ENTER:" Do While Lines(file_name) > 0; line=Linein(file_name); If line='' Then Iterate;       /* skip blanks   */ Parse Var line '"PM_InstallObject"' line; If line='' Then Iterate;       /* skip others   */ Parse Var line '"'head'" 'line; /* get header   */ Parse Var line '"'setup'"' .;  /* get setup string */ Parse Var head title';'object';'location';'. ; Say title "- Yes/No/End ?"; Pull reply ; If Left(reply,1) ='E' Then Leave; If Left(reply,1) <> 'Y' Then Iterate; If SysCreateObject(object,title,location,setup,'Update') = 0 Then Say 'Error creating:' title; Else Say title 'created !'; End; rc=Stream(file_name,'C','Close'); Return 0       /* enjoy your desktop! */ /*  Did you delete your Command Prompts ? Shredded your Shredder ? This program restores the standard WPS desktop objects on 2.x. It will preserve any current settings/objects you may have created and this is its advantage over the Alt-F1 or MAKEINI method. You will need the latest REXX fixes (REXX20 available in library 17) to make it run correctly on 2.0 GA system, no fixes required on GA+SP or 2.1. */

<< PMWP entries in POPUPLOG.OS2 -- Index -- URL objects >>