Page 1 of 1 1
Topic Options
#29658 - 02/09/25 08:46 PM Set Env variable not working
TRL Offline
Lurker

Registered: 02/09/25
Posts: 3
I want to set an enviromental variable on my NT4 and W2K workstations when they login from my NT4 server. I'm using this

set BLAH=SUBSTR(%computername%, LEN(%computername%) - 4, 4)

to set Blah = the last 4 charecters of the computername but it doesn't work, why???

Top
#29659 - 02/09/25 08:48 PM Re: Set Env variable not working
Jack Lothian Offline
MM club member
*****

Registered: 99/10/22
Posts: 1169
Loc: Ottawa,Ontario, Canada
How do you know it didn't work? (try dropping the set part of the command - print the resulting kix variable to the screen - does it work?)

[ 25. September 2002, 20:50: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#29660 - 02/09/25 10:50 PM Re: Set Env variable not working
Sealeopard Offline
KiX Master
*****

Registered: 01/04/25
Posts: 11161
Loc: Boston, MA, USA
Of course this will not work because you are not expanding the environment variable. Also, you should rather use the build-in KiXtart @WKSTA macro.
code:
$computername=expandenvironmentvars('%COMPUTERNAME%')
set 'BLAH='+RIGHT($computername, 4)
$computername=@WKSTA
set 'BLAH='+RIGHT($computername, 4)



[ 25. September 2002, 22:50: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#29661 - 02/09/25 10:58 PM Re: Set Env variable not working
Jack Lothian Offline
MM club member
*****

Registered: 99/10/22
Posts: 1169
Loc: Ottawa,Ontario, Canada
Good point jens!

TRL,

I realized you were blending & confusing the NT command environment & the kixtart environment & Jens re-inforces this point.

With kixtart you can probably forget the NT command environment completely. Do everything in kixtart. Why are you trying to retain this variable?

[ 25. September 2002, 23:00: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#29662 - 02/09/26 05:03 PM Re: Set Env variable not working
TRL Offline
Lurker

Registered: 02/09/25
Posts: 3
Thanks for your help on this. It's one of those projects you're suddenly presented with that requires that you master a complex subject in next 24 hours. So when I ask questions you assume I'm an idiot.

The variable is required by our SQL hotel system application. They have asked us to set this variable in System\Enviromental Variables for each workstation. Well, I'm lazy and I don't want to do this on 200 workstations.

I tried some of your ideas. The trouble is I'm trying to verify the success of the script by opening a command prompt and entering the set command. I don't see the variable. You may tell me I can verify it within the KIX context but how do I know the application is aware of it? It seems to me that I have to see it within the SET context.

But then I'm an idiot with 18 hours of knowledge on the subject of KIX.

Thanks, Tim

Top
#29663 - 02/09/26 05:04 PM Re: Set Env variable not working
TRL Offline
Lurker

Registered: 02/09/25
Posts: 3
Sorry that should read, "you CAN assume I'm an idiot".
[Smile]
Tim

Top
#29664 - 02/09/26 05:21 PM Re: Set Env variable not working
Jack Lothian Offline
MM club member
*****

Registered: 99/10/22
Posts: 1169
Loc: Ottawa,Ontario, Canada
It's a long time since I played with environment variables so I am a bit rusty but my understanding is:

When you go to the command prompt you are creating a new daughter environment that I believe should contain all the variables defined in the current base NT environment at the moment of creation of the daughter.

If the kixtart script has fully completed & all the daughter shells associated with it are fully closed before you open the command prompt then I believe the result of your set command should show in your command box.

My suggestions - Read the definitions of the set command in the kixtart manual closely - also look at setm command it might help.

Did you make the changes jens suggested? Try printing your variable %computername% to the screen just before the set command to insure it is not empty. (Note also that jens is pointing out that the variable %computername% is not a kixtart variable.)

PS: You can edit your previous text by choosing the button on the left showing a piece of paper & a pencil.

[ 26. September 2002, 17:26: Message edited by: Jack Lothian ]
_________________________
Jack

Top
#29665 - 02/09/26 05:30 PM Re: Set Env variable not working
Richard H. Administrator Offline
Administrator
*****

Registered: 00/01/24
Posts: 4945
Loc: Leatherhead, Surrey, UK
A way to check if it is all OK in the local environment is:
code:
SETL "TESTVAR=foo"
SHELL "%COMSPEC%"

That'll start a child DOS session that you can check for TESTVAR.

I've used SETL as I'm testing on a Win95 box.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Chris S., Glenn Barnas, ShaneEP, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 104 anonymous users online.
Newest Members
KristopherMallor, B1GHawkeyes, GeoHamm, register, Marcus_Dunne
17398 Registered Users

Generated in 0.145 seconds in which 0.07 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org