Solved

Unique Environment Variables in 98

Posted on 1998-12-14
25
300 Views
Last Modified: 2013-12-28
This question is going to require some thought folks, but if you come up with the right answer, it will be well worth it. Please read carefully.

This question involves NT login scripts, but knowledge of NT is not necessary to solve the problem, since the answer, I believe, lies within Windows 98.

I have 33 machines in a room and each is an exact duplicate of the other (via. drive cloning software). Each logs into an NT domain with the same user id and password. Each machine has a unique machine name. The machine name is the ONLY unique identifier that is manually configured after cloning. For ease of administration, there will be no other uniqueness, other than that which is required to participate in networking (mac address, machine name, ip address via. dhcp).

Now the tough part. I would like each machine to retain a unique file. Previously, every machine had a copy of each of 33 unique files on the hard drive and each user could pick the file appropriate to them. This is no longer acceptable. It is also not acceptable to place the files on the server since each user must log in with the same network id, which would give them access to all of the same files. I need each machine to contain only the file that is appropriate to that machine.

My proposed solution:
In Windows NT, I could have the login script check for a unique environment variable, such as the computername.

Example:

If %COMPUTERNAME% == Student-1 Goto Unique1
If %COMPUTERNAME% == Student-2 Goto Unique2
Goto End

:Unique1
Copy \\server\unique_file.001 C:\  /Y
Goto End

:Unique2
Copy \\server\unique_file.002 C:\  /Y
Goto End

:End

This login script(for those unfamiliar with NT, this is really just a batch file that runs whenever the user logs in), would check the computername, then copy the appropriate file from a location on the server to the local machine. This works for NT Workstation clients, but not for Windows 98 clients. The reason is that Windows 98 does not create an environment variable for "computername" by default. Adding the variable via. the "set" command, would mean that each machine would have to be unique and if that were the case, I might as well manually copy the appropriate file to each machine after cloning.

I am looking for either an environment variable that 98 adds by default (I have used the set command to check them and found nothing) or an acceptable alternative. An acceptable solution will be worth 500 points provided:

1. It does not require manual configuration of any PC. Everything must either be done from the login script (batch file), or some other automated process.

2. The solution cannot be machine specific as the PC images are wiped and "re-cloned" on a frequent basis.

3. The solution cannot be login specific since each PC must login with the same username and password.

4. The solution must be simple enough that it can be implemented each time after cloning. Prefferably this would be something in the login script that could run each time.

5. Premature answers will be immediately rejected in order to keep this question unlocked. I will request an answer from an Expert once an acceptable solution, given via. comment, has been implemented and tested.

6. While the answer of "It cannot be done . . ." may be the correct answer, it will not be worth 500 points. I know it cannot be done as I have tried to do it (i.e. the computername environment variable) but I am looking for similar alternatives. If a similar alternative cannot be found, the closest workable solution will be accepted as an answer and I will adjust the point value as I see fit.

I will try to respond quickly to your questions.
Thank you and good luck.
0
Comment
Question by:mbreuker
  • 9
  • 5
  • 4
  • +5
25 Comments
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
Edited text of question
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
Edited text of question
0
 
LVL 6

Expert Comment

by:sgenther
Comment Utility
I suggest using Dbset.exe to customize setup scripts and other text files. This is a 98 utility. With Dbset.exe you can easily individualize setup scripts and other types of text files. For example, you can create a template setup script with settings that you want to use for all users in your organization or workgroup. Then, you create a database file with specific data for each user, for example, user_name, computer name, and so on. From the template and database file Dbset.exe creates an individualized setup script by replacing the variable names (for example user_name) with the actual name of the user (for example, Maria). With Dbset.exe, you can also customize other types of files, such as registry files and write environment variables.

0
 
LVL 6

Expert Comment

by:sgenther
Comment Utility
Her is more info on Dbset.exe:
You can use Dbset if your installation requires more customization flexibility than just being able to set the computer name or IP address. Dbset.exe is a configuration utility that allows you to individualize setup scripts and other types of text files. Dbset.exe searches and reads data from a text file (called database file in this section) and uses the data to either set environment variables or to write to an output file using a format specified by a template file. The template file can be a text file in Msbatch.inf format, a registry file, or any other type of text file.
For example, you can create a template setup script (in Msbatch.inf format) with settings that you want to use for all users in your organization or workgroup. Then, you create a database file with specific data for each user, for example, user_name, computer_name, and so on. From the template and database file, Dbset.exe creates an individualized setup script by replacing the variable names (for example user_name) with the actual name of the user (Maria).
The following examples show the syntax of the command, how to use it, and the results you obtain. In this section parameters enclosed in brackets [ ] indicate that the parameter is optional. If a value is not specified, Dbset.exe uses the default value. All the examples use the same database and template file introduced in the first two examples.
Using the Dbset.exe Command-Line Switches
Dbset.exe provides switches (some times called options) to control how it searches and reads data from a database file and how it uses the data to either set environment variables or how it writes the data in an output file.
These switches are specified on the command line as arguments for the dbset command (such as dbset /r). The specific option is preceded by a forward slash (/) character (not the backslash used to specify directory arguments).
Action
Writes data from an input text file, such as a database file, to either set MS-DOS environment variables or to write data to an output text file. If a text file is specified as the output, the data is formatted based on a template text file.
Syntax
dbset      [/d [database_file]] [/f [field_name]] [/s:delimiter] [/i [template_file]] [/r [output_file]] [/m] [/o record_overlay] [/y] [data]
Parameters
delimiter
Specifies the character used to separate one field from another in a record in the database file.
field_name
Specifies the name of the field to be searched.
database_file
Specifies the name and location of the database text file.
record_overlay
Specifies a record with delimiters separating each of its fields.
template_file
Specifies the text file you want to use as a template for formatting data written to the output file.
output_file
Specifies the name of the output file where the data will be written.
Data
Specifies the data item to search for in a database file. The default is to search for the match of “data” in the first field of each record in the database file. To specify another field to search, use the /f switch.
Switches
/d database_file
Specifies the name and location of database file. The default is Dbset.db. The database file contains records or structures of information separated into fields by delimiters. Each record has the same format as the first record in the file. The first record in the file also assigns the name, or data element, of each field. The field names are the same in every record in the file and are the logical definitions of the fields. In each record following the first the fields hold data items or the actual data. For each field name there can be many fields in the database file that hold data items. At a minimum, a database must contain one record which contains the field names. A one-record database is useful only when using the /m switch.
/f [field]
Specifies a field (by name) to search for a data match in. The default is the field that makes up the first column. A field is a unit of data in a record. A collection of fields, separated by delimiters, make up a record. A data item is the actual data stored in the field.
/s:delimiter
A character used to separate one field from another in a record. The default is a comma (,). Only one character may be specified as the delimiter.
/i template_file
Specifies the name and location of the template file. The default is Template.txt. The template file will be used as the basis for the output file. Variable names in the template file are denoted in %variable% format. Actual % characters are denoted by %%. The variable names will be matched with field names in the database file and replace with the values from the appropriate record. Variable names in the template file must match field names in the database file. If the /i switch is specified, the output is always a text file.
/r [output_file]
Specifies the name and location of the file to write to. The default is Dbset.txt. Text written to the output file will be in the format of the Template.txt file with the variable names replaced by data items from the database file.
/m [data]
Specifies to prompt for each variable or field. A “data” argument may be used to specify the record to search for in the database file. The specified data from the record will be used as the prompts. When using the /m switch, your database can contain only the record that contains all the field names you want to use.
/o [record_overlay]
Overwrites the data item of the field specified. The “record_overlay” is a record with delimiters separating each field. Each field should be empty except the field to be overwritten which should contain the new data item. Only the data in the output is changed, data in the database file is not. The new data item may not contain spaces.
/y
Answers yes to all warning messages. This allows for full automation for use in scripts, such as MS-DOS.bat files
/?
Show the help screen.
Input Files: Database or Template Files
Dbset.exe accepts two types of files as input: database and template files, both in text format.
A database file is made up of records. Each record consists of a collection of fields, separated by delimiters. (A field is a unit of data.) The first record in the file specifies the field names. The actual data, stored in the fields differ, while the field names are logical definitions of the fields and are the same for each record in the file. Field names need to match with variable names in the template file.
The following shows an example of a database file.
 
name,machine,staticip,mailsvr
Dan,dev_02,172.30.5.1,mail-svr-70
Sam,dev_01,172.31.55.5,mail-svr-59
Pasquale,dev_03,172.25.25.1,mail-svr-40

 
A template file, whose default name is Template.txt, contains the format used to write to an output file with variable names denoted as follows:
%variable_name%
If the percent sign (%) is part of any text in the template file, other than where variables are specified, the percent sign should be denoted by %%. Dbset.exe replaces %% by % in the output file, when the output file is created.
A template file does not need to contain all the variables in the database, but the database must contain all the variables in the template file. If the template file contains variables that are not represented in the database file the following error appears:
 
Error! Wrong template file

 
Creating a Template File
You can create template files from a variety of text files. For example, from the following registry file:
 
[HKEY_CURRENT_USER\Dbsetexample\Profile\Sam]
"User"="Sam"
"MachineName"="dev_01"
"IP"=172.31.55.5
"Server"="mail-svr-59"

 
Note   All the examples that follow use these sample files as input files.
Example
You can create a template file that looks like this:
 
 [HKEY_CURRENT_USER\Dbsetexample\Profile\%name%]
"User"="%name%"
"MachineName"="%machine%"
"IP"=%staticip%  
"Server"="%mailsvr%"

 
Changing the Default Database File Name
The following example demonstrate how to use a file name other than the default name for a database file (Dbset.txt is the default database file name).
To change the default name for the database file
·      Use the following syntax:
      Dbset /d database_file data
 
Example
If you type:
Dbset /d MyDatabs.dbs /r Dan
Dbset.exe searches the file MyDatabs.dbs for the item Dan in the Name field and writes the data it found to the default output file, Dbset.txt, using the format of the default template file, Template.txt.  
Example
If you type:
Dbset /d MyDatabs.dbs Dan
Dbset.exe finds the same data as in the previous example but it writes it to environment variables instead of an output file because neither the /r or /i switch were specified.
Changing the Default Search
The default Dbset.exe behavior is to search for the match of the data specified, in the first field of each record in the database file. In the sample output file described earlier, the data searched for was Sam in the Name field, which is the first field of each record. To specify another field to search for the data in, use the /f switch.
To search a field other than the default
·      Use the following syntax:
      Dbset /f field data
 
Example
If you type:
Dbset /f machine dev_02
Dbset.exe searches for dev_02 in the Machine field in each record in the file. Then Dbset.exe writes the data found in the record to environment variables.
Using Delimiters
A delimiter is a character used to separate one field from another in a record. You can specify only one character as the delimiter. The default is a comma (,).
To use a delimiter other than the default
·      Use the following syntax:
      Dbset /s:[delimiter]
 
Example
The following two examples show how to specify a character as the delimiter in the database file. When you execute:
Dbset /s:; Sam
Dbset.exe accesses the default database file and use the semicolon (;) as the delimiter. It then finds the data Sam in the Name field of a record and uses the data to write environment variables.
Changing the Default Template File Name
The following example demonstrate how to use a file name other than the default name for a template file (Template.txt is the default template file name).
To use a template file other than the default
·      Use the following syntax:
      Dbset /i template_file data
 
Example
If you type:
Dbset /r /i Temp.txt Sam
Dbset.exe uses Temp.txt as the template file instead of the default template name, Template.txt.
Creating Globally Unique Identifiers (GUIDs)
The database file can contain the variable $guid8$ and $guid10$. These entries in the database create a globally unique identifier (GUID), with either 8 or 10 characters, which is guaranteed to contain one or more of each of the following: capital letter, lower-case letter, number, or symbol.
Example
If you use the following database file, which contains GUID entries:
 
Name,machine,machine2,ID
johnd,jdoe,jdoe2,$guid8$
sohanl,v-samano,v-samano2,$guid10$
dspinn,dansp,dansp2,$guid10$

 
And you type:
Dbset johnd
Dbset.exe writes to environment variables the data found in the record, of the default database file, with “johnd” in the Name field. The environment variables might look like:
 
name=johnd
machine=jdoe
machine=jdoe2
mailsvr=sD8P9x,e

 
Output: Environment Variables or Output File
Dbset.exe supports two types of output: environment variables or a text output file.
Using Environment Variables as Output
When the specified output is writing to environment variables, Dbset.exe sets the environment variables specified by the field names of the database
Note   To check the environment variable settings, type set at the command prompt.
To use environment variables as output
·      Use the following syntax:
      Dbset data
 
Example
If you type
Dbset Dan
Dbset.exe writes the data from the record called dan to environment variables as follows:
 
name=dan
machine=dev_02
staticip=172.30.5.1
server=mail-svr-70

 
Using a Text File as Output
Dbset.exe can also write to an output text file. To generate an output file, you must provide a template file. Text written to the output file will be in the same format as the template file, with the variable names replaced by data items from the database file. The default output file name is Dbset.txt.
To specify a text file as output
·      Use the following syntax:
      Dbset /r [output_file] data
 
Example
If you type:
Dbset /r Sam
Dbset.exe writes the data from the Sam record to the default output file (Dbset.txt) in the following format.
 
 [HKEY_CURRENT_USER\Dbsetexample\Profile\Sam]
      "User"="Sam"
      "MachineName"="dev_01"
      "IP"=172.31.55.5  
      "Server"="mail-svr-59"

 
If a template file is specified, the output will automatically be a file based on the template.
Example
If you type:
Dbset /r /i Temp.txt Sam
Dbset.exe writes the information it found in the record with the data Sam in the Name field, to the default output file in the format specified by Temp.txt.
Example
If you type:
Dbset /r MyOutput.txt Sam
Dbset.exe creates the file MyOutput.txt (if the file exists a prompt to overwrite the file will appear) and writes to it the information from the record that contains the data item Sam in the Name field. The data is written to MyOutput.txt in the same format as the default template file. If the default template file, Template.txt, does not exist, the following error message is displayed:
 
Error! Wrong template file!

 
Prompting
You can use Dbset.exe to prompt you to enter the data for each field of a record in the database file. You can specify a record that Dbset.exe will use to prompt you, or if you do not specify a record, Dbset.exe prompts you to enter the data. The database file is not modified.
To cause Dbset to prompt you for the data for each field
·      Use the following syntax:
      Dbset /m [data]
 
Example
If you type:
Dbset /m Sam
Dbset.exe accesses the default database file and displays the data in each of the fields of the record that contains Sam in the Name field. The user is prompted with each field one at a time, and has the option to edit the data. After Dbset.exe displays each field, it writes the data to environment variables.
For this example the data that Dbset.exe prompts to the user and the environment variable settings are as follows:
 
name=Sam
machine=dev_01
staticip=172.31.55.5
server=mail-svr-59

 
Example
If you type:
Dbset /m
Dbset.exe prompts the user to enter data for each of the fields in a record in the default database file. Then, it writes the data the user entered to environment variables.  
Example
If you type:
Dbset /m /r
Dbset.exe prompts the users in the same way described in the preceding example but it writes the new data to the default output file (Dbset.exe) using the format of the default template (Template.txt).
Important   When the /m switch is followed with other switches, Dbset.exe assumes that the last parameter belongs to the switch specified last.
Example
If you type:
Dbset /m /r Output.txt
Dbset.exe prompts the users in the same way described in the preceding example but it writes the new data to Output.txt, using the format of the default template (Template.txt).
Overwriting Data in a Field in a Database File
You can use the /o switch to overwrite a data item in a field of the database file. To specify which field to overwrite, type the /o switch followed with as many delimiters as there  are in the record of the database file. Leave each field empty except for the field you want to overwrite. In that field, type the new data. Using this /o switch does not change the data in the database file, only the data in the output is changed. The field and the new data item can not contain spaces.
To change the default name for the database file
·      Use the following syntax:
      Dbset /o record data
 
Example
If you type:
Dbset /o ,dev_06,, Dan
Dbset.exe overwrites the data that exists in the second field (the Machine field) of the record that contains Dan in the first field (the Name field) with the new data dev_06.
Example
The following example combines several of the switches used in the previous examples in the following syntax:
Dbset /d [database_file] /r [output_file] /f [field] /i [template_file] data      
Using:
database_file = Database.db
output_file = Output.txt
field = machine
template_file = Temp.txt
data = dev_03
When you execute:
Dbset /d Database.db /r Output.txt /f machine /i Temp.txt dev_03
Dbset.exe accesses Database.db and the data dev_03 in the machine field of a record. It overwrites the variables of Temp.txt with the data it found. It writes this information to the output file Output.txt using the format of Temp.txt.

 

0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
Thank you sgenther, however I am not setting up or installing software. If I was, I might use scripts to automate and customize the various aspects of the setup. What is happening is that I have 33 PCs, each with the exact same hardware and software, in a training room. Because the time between classes is so short, I do not have the luxury of re-installing new software or changing configurations in between each class.

What I do is have each instructor tell me what is needed before each class and we install software and/or configure the PC to accomodate. After the instructor tests and approves a new configuration, a Ghost image is made of the drive and each of the other 32 PCs are overwritten to accept the new configuration. The drives are overwritten to ensure that previous students did not tamper with the configurations of the machines and render them unuseable in some way. This method gaurantees consistency.

Since the machines use DHCP, the only thing that needs to be changed after the cloning, is the machine name - which is manually changed inside network control panel. This step is time consuming in itself and I do not wish to further extend this time by performing additional steps at each PC.

Now, in one particular class, each student needs to have a "key" file. We will call these key.001 through key.033. What I have done was copied each and every key to the "master" hard drive so that the cloned PCs have the keys that they need and the students can just open the key that they need. I have been told this is not acceptable. Each PC must have one and only one unique key. The proposed solution was to have each student log in with a different ID (Student-1 though Student-33) and each account would be exactly the same except that they would have each a user directory with the appropriate key in it. This was also unacceptable because they wish to have every student log in to the NT server with the same ID.

Even if I broke down and manually copied each appropriate key to each appropriate workstation (ie. copy key.001 to station-1 and so on), I would have to repeat this process everytime there is a new class and thus a new drive "image."

As I said before, the only unique things to each machine are the MAC address, IP address, and NetBIOS machine name. I could easily create a login script to read any of these variables if they existed on the windows 98 machine. Apparently they do not.

Before we get any further on this, I am working on a solution. I use 32 boot disks to boot each machine with during the cloning process (for Ghost Multi-cast). This ensures that each PC is booted at the same time, rather than one at a time. I am working on adding to the autoexec.bat file of each boot disk a line item to create a unique environment variable on the autoexec.bat file of the local C: drive aftger cloning is complete. If I do this, I will have to manually edit each of 32 diskettes and label them for use i\only in the appropriate machines, but then my login script will function and I can save a lot of time in the future if I need to make any machine specific changes. This is the way I wanted to do it because NT has the environment variable %COMPUTERNAME% in memory by default. I was hoping 98 had something (anything) similar - not just machine name but any unique variable.

I hope this helps you understand my problem and where I am trying to go with this. If anyone can come up with a better solution than the one I have proposed for myself, one which meets all my needs, I will consider your answer and award points.
0
 
LVL 2

Expert Comment

by:skybird
Comment Utility
The unique environment variable I think you are looking for in Win98 exists in the registry.  (I may be wrong on what you are looking for and dont ask me how to use it)  I am just proposing where you might find your unique identifier for each machine.

Look at the key...

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName

0
 
LVL 3

Expert Comment

by:cbo120897
Comment Utility
Puhh, this is a very long english text, because I am German....
But, I think I have the solution:

During your logon-script you must put the computername to the environment (You know in NT this is %COMPUTERNAME%).
 
The following batch file works fine for Win95 and I hope the same for Win98:
----------------------------------------------------------------
@echo off
REM Put the computername to the environment variable USER
net config | find "Computername" | sed.exe -e s/Computername\x20*/set\x20Computername=/ > name.bat
call name.bat
REM Now you can use the %COMPUTERNAME% varibale in this batch
REM If %COMPUTERNAME% == Student-1 Goto Unique1
REM If %COMPUTERNAME% == Student-2 Goto Unique2
REM and so on ....
-----------------------------------------------------------------

Description:
'net config' : show the current computer (and more)
'| find "Computername"' : seperate the line with the name
'| sed.exe ....' : modify the line with the streamline editor
'> user.bat' : change the output to a batch file

I hope, you are familiar with pipes ('|'). Further I use the streamline editor to modify a line on DOS promt. The command looks very difficult ...., but it's easy.

The command 'sed.exe -e s/from/to/ [filename]' will change the 'from' into 'to'. So I change the line
'Computername                somename'
into
'set Computername=somename'

\x20 means one space
\x20* means all spaces


I have one problem, because I work on a german NT, so I don't know, how the line shows from the 'net config' command (on other Win98). I think there is a 'Computername'. When not, you must change the 'Computername' at all places to the right word.

The tool 'sed.exe' can be found in the WEB at (http://www.partner.europe.digital.com/www-swdev/pages/Home/TECH/software/pdaxpnt.html) or I can Mail it to you. The description for the command can also be found in the WEB. Search for '+grep +manual'.

What do you think?
0
 
LVL 6

Expert Comment

by:bartsmit
Comment Utility
Try this one with good old fashioned batch file commands.

Add the following lines to the autoexec.bat of the win98 stations:

regedit /e name.txt HKEY_LOCAL_MACHINE\System\CurrentControlSet\control\ComputerName\ComputerName
find "tom" name.txt
if errorlevel 1 goto dick
if errorlevel 0 set computername=tom
:dick
find "dick" name.txt
if errorlevel 1 goto harry
if errorlevel 0 set computername=dick
:harry
find "harry" name.txt
if errorlevel 1 goto end
if errorlevel 0 set computername=harry
:end

Fill in all the possible computernames for tom, dick and harry and make sure that the regedit line is unbroken.
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
CBO,
Thank you, that was a very interesting solution which I will try. I have never used the SED utility, but will try it nonetheless. I am rejecting your answer for now, as I mentioned in my original question that immediate answers will automatically be rejected.

BARTSMIT,
Thank you. That is almost exactly the kind of thing I was looking for. I new the computername existed in the registry, but wasn't sure exactly how to extract that information and then use it in the batch file. Unfortunately the regedit.exe command is disabled at each of the student PCs for "security" reasons. I will first try CBO's suggestion of using the "net config" to show the computer name and using the SED utility to add it to the environment. If this proves unworkable or overly complex, I will try your suggestion, even if it means re-enabling the registry editor on the workstation.

CBO and BARTSMIT,
I may try a combination of both suggestions. Using a command such as
NET CONFIG > config.txt
find "station-01" config.txt
if errorlevel 1 goto Student-1
 . .

If this works out, I will split the points between you in an equitable fashion.

In the meantime this question remains open to anyone who might provide a better solution.
0
 
LVL 3

Expert Comment

by:cbo120897
Comment Utility
Hi mbreuker,
in NT the command 'for' can split a line into his words. So I extract words in NT with this command (not with the sed.exe). But I don't know, if Win98 is having this functionality. When the command 'for' is having the options 'skip' and 'tokens' then you can use 'for' in place of 'sed'.

I think the solution with "net config" + "find ..." ist very stabil, but you can only search for known names...

Only with my solution (if it works) you get any computername in the environemnt.

Bye and good tests
cbo
0
 
LVL 6

Expert Comment

by:bartsmit
Comment Utility
why not delete regedit.exe as the last part of the autoexec.bat. You can always run it from the server or from diskette if you get stuck.
0
 
LVL 3

Expert Comment

by:cbo120897
Comment Utility
I don't understand your comment bartsmit. Why do you wont to delete the executable?

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 6

Expert Comment

by:bartsmit
Comment Utility
cbo:

Since there is a "security" issue of students attempting to wreck the setup by running regedit, it is safer when it is deleted off the hard drive.

To prevent undeleting mbreuker could even overwrite it with a small text file, lecturing about the bad karma that comes from hacking.

If there is a copy on diskette or (in case of dickless workstations) on the server, mbreuker can still solve any problems on the setup. This is unlikely to be needed since the lifespan of his windows setup is only a class session.
0
 
LVL 5

Expert Comment

by:jboddy
Comment Utility
Have you thought of using policies, so you can logon as administrator and use regedit, but the students cannot??
0
 
LVL 7

Expert Comment

by:MATTCEI
Comment Utility
There is one unique identifier for every networked PC that is embedded in firmware,and thus unrelated to any software: the network interface card's node address.
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
joboddy,
I do use policies. This is why regedit does not work. Since the proposed solution involves running regedit in the student's login script, and it is the student who's policy disables regedit, this does not work. The option of deleting regedit is a consideration, but I have a larger problem . . .

bartsmit or cbo,
It appears that the "find" command does not produce an errorlevel value. If I perform the function
find "station-01" c:\config.txt
if errorlevel 0 goto Student1

On the command line, I receive the output
--------------- config.txt
if it does not contain the string and
computername         \\station-01
if it does contain the string

In either case, the batch file treats the errorlevel as 0 and executes the first statement. I would really like to implement this as the solution, what can I do? Thanks.
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
Thank you MATTCEI, but as I indicated in my question, I am aware that there are 3 unique identifiers - the MAC address (NIC firmware), IP address (via. DHCP), and the NetBIOS computername. These values exist in the registry of the computer - but knowing this does not solve my problem. The problem is that I must have the login script check for this identifier which is really easy if it exists as an environment variable which the login script can check for, but it does not.
0
 
LVL 6

Expert Comment

by:bartsmit
Comment Utility
Find *does* produce an errorlevel but you need to check for them in descending order. I.E. check for 2 and 1 first and then for 0. If you check for 0 first, the value will be voided.
0
 

Expert Comment

by:steath_acid
Comment Utility
Are you saying that they all log on under the same username and password but you want profiels machine specific?  If so don't you think it would be easier to give everyone different passwords and set acsess to folder thru NT.
..
I know that that is not an answer to you question just a sugestion, so here is my ideal about an answer:

Your batch file does work correct but Win 98 just will not run it correct??  If so add it to the Start Up section of each computers Start Menu it should then run and load everything corectly but since you are worried about security you could add it to Win.ini.
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
Thanks Stealth_Acid.

I actually use the same username and password and the same profile on each machine and each machine is an exact clone of the other. I initially thought about unique usernames and passwords (ie. Student1, Student2, etc.) but the classroom instructor has asked me not to, since this would mean a name/password would have to be distributed to each user somehow. I know this sounds trivial, but I am trying to be accomodating to the instructors wishes. The only problem here is that each user must have a different user.id file (for Lotus Notes). I copied all of the 33 IDs on the first machine and when I "cloned" the PCs, each had a copy of all the user.id files (user01.id through user33.id). The instructor did not like this as she felt that a user could accidentally use the wrong ID since they all had the same password. I suggested giving each user.id file a unique password but the instructor rejected this idea for the same reason she rejected the idea of each user logging in to the NT server with a different username.

My thought when writing this question was to put no IDs on the workstations and store them all on the server. Then, during login, have the login script read the machine name somehow (or other unique variable) and copy the appropriate ID file to the data directory on the local C: drive. If I manually copy the files to each machine or otherwise make unique changes to each local machine, then those unique changes will be wiped out the next time I clone the drives, which is usually between classes. While I have the last word on the network for this lab, I would still like to get kudos for creatively accomodating the instructors rather cumbersome request.

Well anyway, the batch file behaves the same whether executed as a login script or run locally. I am going to rearrange the order of the errorlevel checking as per bartsmit and see what happens. It may be a day or two before I get a chance to try this again. In the meantime, keep the suggestions coming.
0
 
LVL 3

Expert Comment

by:cbo120897
Comment Utility
Hi mbreuker,
I use the find-errorlevels at follows:
---------------------------------------------------------------
find "person" test.txt > NUL
IF ERRORLEVEL 1 GOTO NO

:YES
REM person found
REM do something
GOTO END

:NO
REM person not found
REM do something
GOTO END

:END
----------------------------------------------------------------
bye cbo
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
BARTSMIT and CBO,

Thank you both. I now have a functioning login script that correctly identifies the PC by its NetBIOS name. Since the solution required a combination of efforts, cbo's suggestion of using the NET CONFIG command to extract the computername and bartsmit's suggestion of using the FIND command to search the output of a file and use the errorlevel check, I have decided to split the points evenly.

The final batch file looks something like this:

@Echo Off
NET CONFIG > c:\config.txt

:StartID

:Instructor
FIND "Instructor" c:\config.txt >NUL
If ERRORLEVEL 1 Goto Studen1

echo "This is the Instructor PC"
REM Insert machine specific instructions here
Goto EndID

:Studen1
FIND /I "Student-01" c:\config.txt >NUL
If ERRORLEVEL 1 Goto Studen2

echo "This is Student-01"
REM Insert machine specific instructions here
Goto EndID

<more of the same>

:Error
echo "This script failed to identify the machine"

:EndID

<Rest of login script follows>

CBO,
Since you answered first, please submit an answer for 250 points. Thanks for your last minute help on getting the errorlevel check to work. I didn't realize how limiting this function was, but once you understand the limitations, it is easy to work around them.

BARTSMIT,
Thanks for your help. I could have avoided the additional complications if I had followed your first example concerning the errorlevel check. Nonetheless, I have learned something valuable. Please go to the question labeled "For bartsmit only" to collect your 250 points."
0
 
LVL 3

Accepted Solution

by:
cbo120897 earned 500 total points
Comment Utility
Nice to can help you.
0
 
LVL 2

Author Comment

by:mbreuker
Comment Utility
I am trying to "decrease" the points to 250. If it doesn't work for some reason, you will get the full 500. Enjoy.
0
 

Expert Comment

by:steath_acid
Comment Utility
I realize you already have an answer but with the functing batch file you could place it in the load= section of win.ini and it would run on every computer.  Also since security is not the most important thing on your network you could instal TweakUI from you WIN98 DC (tweakui.ini) and tell it to auto logon to the network.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Windows Mobile Barcode Scanning These days almost every product has a barcode in some way... amongst there are 1D barcodes en 2D barcodes.. From http://www.barcodeman.com/faq/2d.php I found some handy definitions and insights. 1D barcodes …
Several part series to implement Internet Explorer 11 Enterprise Mode
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now