Discussion Locked

Logon script variables

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need to have variable set when a user logs on. For instance, on my old Novell server, I have:

set cobdir=g:\data

I tried putting the above in the logon.cmd that a user runs, but the variable is not set.

Thanks for any help,
Nick

6 replies

by joseph moore

Well, you are setting up the variable correctly. Maybe you are just calling it incorrectly. Here is a sample file that sets up a COBDIR variable that points to a directory, then it displays what the variable equals; last, it does soemthing with the variable:

@echo off
set cobdir=c:\mp3
echo The COBDIR variable is %cobdir%
dir %cobdir%

And here is the screen output when you run this:

The COBDIR variable is c:\mp3
Volume in drive C has no label.
Volume Serial Number is 6877-859B
Directory of c:\mp3

05/06/2002 12:10a
.
05/06/2002 12:10a
..
04/29/2002 03:21p
Assorted
04/29/2002 03:23p
Delerium
04/29/2002 03:23p
Haujobb
03/08/2002 08:50p
Project Pitchfork
04/29/2002 03:22p
KMFDM
04/29/2002 03:22p
Lacuna Coil
05/06/2002 12:18a
Moby
04/18/2002 01:27a
Theatre of Tragedy
04/29/2002 03:21p
Type O Negative
05/08/2002 07:30a
Within Temptation
0 File(s) 0 bytes
12 Dir(s) 2,507,538,432 bytes free

So, rememerber to call the variable using the %VARIABLENAME% syntax, but use only VARIABLENAME when you set up the variable.

hope this helps

by beermonster

Hi,
The problem you are having is that the set command assigns a variable only for the duration of the command session. In other words as soon as the command window that runs the login script closes, the variable 'ceases to exist'. there is a util in the reskit designed to create more permanent system variables in either the user or computer environment,it's called setx.exe

Hope this helps....

This discussion is closed to new replies.