Originally Posted By: itdaddy
 Quote:

shell "cmd.exe /c for /F %%a in ('findstr /c:BULLSEYE\ c:\find.txt') do set FindName=%%a"


Like this works onthe command prompt
and then you type the word SET and it shows up
FINDNAME=DOMAIN\USerA

but for some reseason it sets it fine in kix shell but
doenst retain the value of FINDNAME?

Child processes are like teenage children.. old enough to drive but not old enough to put gas in the car. ;\)

When you run such a command from a "DOS" window, you own the resources.
SET PIE=BLUEBERRY
You now have a blueberry pie in your environment
CMD
You now have a (teenage) child process. You, being a mature adult, have shared your pie. A SET will confirm that the blueberry pie is there.
SET PIE=CHERRY
SET CAKE=CHOCOLATE
Your child eats the Blueberry pie and bakes (himself) a Cherry pie. Since the oven's hot, he bakes a chocolate cake. SET shows both in his environment.
EXIT
He leaves, heading to hang with his buds..
Look around..
SET
Hey! Where's the cake? Why do I have this old Blueberry pie and not some fresh Cherry pie? (In typical teenage fashion, you hear "Oh, did ya want some of that?" as he drives away.

Computer processes have a similar parent/child relationship (without the cost of gas). When you run a command, it establishes an environment, with a set of values. When that command runs another external command, it (the "child" process) establishes its own environment, starting with a copy of the parent process environment. The child is free to do anything it wants to its environment, knowing it won't affect its parent or any other sibling. Thus, when the child process terminates, its environment is destroyed.

The commands you enter at the command prompt are being run IN the current environment - you are not spawning a child process, so the results affect the current environment.

When you run a Kix script, it establishes an environment. You SHELL to a CMD shell to run the same commands - this creates a child environment where the environment var is created, and then destroyed when the shell exits.

Basically, what you're trying to do is not possible using environment vars. That's why there are other tools to run sub-commands and return data, such as WSHPipe(). Still, everything you want to do can be done natively from Kix.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D