Joseph

Distinguished
May 19, 2002
940
0
18,980
Archived from groups: microsoft.public.windowsxp.general (More info?)

How do I use (syntax/other) the SET name=othername in a batch file, on XP,
to set an environment variable?
So far... I've had no luck.

J
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

Joseph wrote:
> How do I use (syntax/other) the SET name=othername in a batch file, on XP,
> to set an environment variable?
> So far... I've had no luck.
>
> J

Using the old style control panel
Control Panel -> System -> Advanced tab -> Environment Variables
 

Joseph

Distinguished
May 19, 2002
940
0
18,980
Archived from groups: microsoft.public.windowsxp.general (More info?)

Thanks Carl,

I do not want the SET to be permanent. I know I can also hand key the new
'SET's from a CMD window, which is very time consuming.

I was looking for a way to 'automate' the job in a batch file (or similar)
so that when I'm done I can undo the SET's.

I've tried most nearly all of the obvious ways I know of, and still no luck.

J


"Carl Kaufmann" <ckaufmann@dksa.com> wrote in message
news:umvK3d8tFHA.996@TK2MSFTNGP10.phx.gbl...
> Joseph wrote:
> > How do I use (syntax/other) the SET name=othername in a batch file, on
XP,
> > to set an environment variable?
> > So far... I've had no luck.
> >
> > J
>
> Using the old style control panel
> Control Panel -> System -> Advanced tab -> Environment Variables
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

Joseph wrote:
> How do I use (syntax/other) the SET name=othername in a batch file, on XP,
> to set an environment variable?
> So far... I've had no luck.

The syntax is as you say:

set variable=value

If you put the following in a batch file, the output to the screen
should be X after running the batch:

@set x=X
@echo %X%

If that is not what you are attempting, post a specific example of what
you are trying to do that is failing.
--
Tom Porterfield
MS-MVP Windows
http://support.telop.org

Please post all follow-ups to the newsgroup only.
 

z

Distinguished
Apr 7, 2004
217
0
18,680
Archived from groups: microsoft.public.windowsxp.general (More info?)

Joseph wrote:
> I was looking for a way to 'automate' the job in a batch file (or similar)
> so that when I'm done I can undo the SET's.

See $ help setlocal and
$ help endlocal
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

On Mon, 12 Sep 2005 14:13:57 -0400 in
microsoft.public.windowsxp.general, Joseph favored us with...
> How do I use (syntax/other) the SET name=othername in a batch file, on XP,
> to set an environment variable?
> So far... I've had no luck.

What does this mean, "no luck"? What are you trying to do, and what
message did you get?

SET name=text works just fine, but it will not survive a reboot. For
that you need to go into System Properties (press Windows+Break
keys), Advanced tab, Environmental Variables button.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

On Mon, 12 Sep 2005 14:37:55 -0400 in
microsoft.public.windowsxp.general, Joseph favored us with...
> I do not want the SET to be permanent. I know I can also hand key the new
> 'SET's from a CMD window, which is very time consuming.
>
> I was looking for a way to 'automate' the job in a batch file (or similar)
> so that when I'm done I can undo the SET's.

See the setlocal command.

Or, create a second batch file with
set A=
set NAME=
and so forth -- that is, "set" commands with nothing after the = sign
will delete those environment variables.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
"What in heaven's name brought you to Casablanca?"
"My health. I came to Casablanca for the waters."
"The waters? What waters? We're in the desert."
"I was misinformed."
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

As standard (ie a programmer doesn't override the default), environments are copied then passed from the parent program to a child program. Explorer starts most programs in Windows.

So (assuming cmd),

Set a=dog
notepad

will start notepad with a variable named a available. If notepad should change this a variable then only notepad's environment is changed, not the calling cmd's.

So start cmd, set your variables (they disappear when you exit cmd), then start any programs from that cmd instance.

To run a batch and leave a command window open use

cmd /k batfile.bat
--
--------------------------------------------------------------------------------------------------
http://webdiary.smh.com.au/archives/_comment/001075.html
=================================================
"Joseph" <joseph.d.hudak@usace.army.mil> wrote in message news:%23r1Sck8tFHA.1168@TK2MSFTNGP10.phx.gbl...
> Thanks Carl,
>
> I do not want the SET to be permanent. I know I can also hand key the new
> 'SET's from a CMD window, which is very time consuming.
>
> I was looking for a way to 'automate' the job in a batch file (or similar)
> so that when I'm done I can undo the SET's.
>
> I've tried most nearly all of the obvious ways I know of, and still no luck.
>
> J
>
>
> "Carl Kaufmann" <ckaufmann@dksa.com> wrote in message
> news:umvK3d8tFHA.996@TK2MSFTNGP10.phx.gbl...
>> Joseph wrote:
>> > How do I use (syntax/other) the SET name=othername in a batch file, on
> XP,
>> > to set an environment variable?
>> > So far... I've had no luck.
>> >
>> > J
>>
>> Using the old style control panel
>> Control Panel -> System -> Advanced tab -> Environment Variables
>
>
 

Joseph

Distinguished
May 19, 2002
940
0
18,980
Archived from groups: microsoft.public.windowsxp.general (More info?)

I want to thank each of you for the information.

As I try, I discover that I can make the temporary enviroment variables,
example: SET DUM=dummy work from a batch file, say dum.bat, but ONLY if I
run the dum.bat file from within a CMD window. Then when the program
finishes I can undo the SET's from the same CMD window. This requires I also
run the program from the CMD window as well.

I was trying to run the batch file from 'explorer' (click on it), which did
not effect the environment changes set within the .bat file. I don't know
why.

The same file run from a CMD window, however, did make the changes.

I do not want to set the variables permanently.

Again thanks, I do have my workaround now.

Joe


"Stan Brown" <the_stan_brown@fastmail.fm> wrote in message
news:MPG.1d8ffd879f6148d398977c@news.individual.net...
> On Mon, 12 Sep 2005 14:13:57 -0400 in
> microsoft.public.windowsxp.general, Joseph favored us with...
> > How do I use (syntax/other) the SET name=othername in a batch file, on
XP,
> > to set an environment variable?
> > So far... I've had no luck.
>
> What does this mean, "no luck"? What are you trying to do, and what
> message did you get?
>
> SET name=text works just fine, but it will not survive a reboot. For
> that you need to go into System Properties (press Windows+Break
> keys), Advanced tab, Environmental Variables button.
>
> --
> Stan Brown, Oak Road Systems, Tompkins County, New York, USA
> http://OakRoadSystems.com/
> "What in heaven's name brought you to Casablanca?"
> "My health. I came to Casablanca for the waters."
> "The waters? What waters? We're in the desert."
> "I was misinformed."
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsxp.general (More info?)

On Mon, 12 Sep 2005 14:13:57 -0400, "Joseph"
<joseph.d.hudak@usace.army.mil> wrote:

>How do I use (syntax/other) the SET name=othername in a batch file, on XP,
>to set an environment variable?
>So far... I've had no luck.

Below is the group where a lot batch discussion resides. The
environmental variable should persist as long as the batch file
that sets it is still running. I think when the batch closes, the
variable is also gone.

alt.msdos.batch.nt