WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Environment

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Detecting Search Drive Mappings

Keywords: environment search drive mappings path 

Question

I'm new to WinBatch. I have a need for a routine -- to detect all network drives and determine if they are mapped as root or search drive; save that info so I can remap some drives to other places and then restore them to the original settings.

Many of my users have most if not all of the drive letters mapped to suit themselves and I need to launch an application that needs temporary use of several drive letters. And to make it worse, some networks are Novell 3.x and others are 4.x; most desktops are Windows 3.1, but some are Win95 and some are Windows for Workgroups, with a few NT systems thrown in for flavor.

I looked at the extender DLL's and netware help files. But I didn't see anything that would tell me if a drive is mapped as root and/or search. Just knowing which drives are mapped doesn't help if I need 5 letters and there are only 3 left unmapped. Since there does not seem to be a way for WinBatch to map a drive as a search drive, I need to avoid "stealing" those letters, because I can't put them back. The users would kill me slowly and painfully if I mess up their search paths. I got this problem dumped in my lap along with a copy of WinBatch, so I need all the help I can find.

Answer:

Ok. Its an ugly scenario. Mapping drives is easy. However, Novell search drive mapping is just a cute trick they pull when Netware maps the drive more or less normally, and then alters the PATH statement internally to add the newly mapped drives to the DOS path.

Basically this is an environment change. Changing the environment can get sticky, as follows:

  1. Windows 3.1 and Windows for Workgroups

    We've solved this problem for you via the "Environment Manager" extender. It can change the environment in 16 bit Windows. No sweat.

  2. Windows NT

    There are documented ways to change the environment in Windows NT in the database. Some sweat, but it works. You modify the registry and send out a WININICHG message. You can search for WININICHG in this tech support database for the relevent article.

  3. Windows 95

    Run for the hills. Environment handling is iffy at best in Windows 95. In certain select cases it can work very well, but outside of that...dead meat.

    If you just want to change the path for a single application -- launched either by Explorer or WinBatch -- you can use the RegApp function. It works great.

    If you want to change it for the entire system, or if the app you launched want to launch another app....too bad.

Here's the overall concept to check if a drive is a search drive, and then remap it:
  1. Read all drive letters with the DiskScan function.
  2. Use n3GetMapped() to obtain a list of drive letters.
  3. Read the PATH environment variable with the Environment("PATH") function.
  4. Do a While loop on the list of drives.
    Use your example to check if the drive is in the PATH.
    If the letter is in the path, it can be saved and remapped.
    EndWhile
Use the n3GetMapped() function to see all the drives that are currently mapped. Use the n3DrivePath() function to allow you to obtain the UNC path where the drive is mapped. The function does not return whether it was a search mapping, a regular mapping, or a ROOT mapping. But, as stated above, in fact, Search Mapping is fake, even in Netware, because it is a combination of mapping the drive and modifying the PATH statement.

If you want to determine if a specific drive is a search drive, try the following script:

        a=Environment("PATH")
        b=strindex(a,"P:",0,@fwdscan)
        if b==@true
           Message("Apparently P:","is a search drive")
        else
           Message("Apparently P:","is NOT a search drive")
        endif

Question (cont'd.)

There is an issue, however. I went to a DOS prompt and typed PATH. I saw the search drives on the PATH environment variable. I attempted to remap Z: to another location. To my surprise, executing MAP to change the location caused the Z:. entry to be removed from the path. "I guess this is a feature in NetWare's MAP command!!"

What do you think about this. Will WinBatch behave in the same fashion?

Answer:

I don't believe so. The NetWare MapSearch function maps the drive and adds it to the path. I guess when you map a drive (instead of mapsearch) and the drive is on the path, it removes it. The WinBatch map functions do not try to combine this functionality. So (in theory) they should not affect the path.
Article ID:   W12914
Filename:   Detecting Search Drive Mappings.txt
File Created: 1999:04:15:16:50:30
Last Updated: 1999:04:15:16:50:30