Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Environment Variable Not Set by setenv command

Subject: Environment Variable Not Set by setenv command

From: Ayrangel

Date: 12 Jan, 2011 15:35:20

Message: 1 of 9

Hi!

I am trying to use the setenv command to change the value of an environment variable defined in Windows XP. After using the command, if I use the getenv command I see the new value. But I still see the old value when I access the variable value thru the Control Panel or if I use the echo %varname% command on the Windows XP command prompt. Thanks.

Subject: Environment Variable Not Set by setenv command

From: I am too much me

Date: 12 Jan, 2011 15:52:03

Message: 2 of 9

On 12/01/11 9:35 AM, Ayrangel wrote:

> I am trying to use the setenv command to change the value of an
> environment variable defined in Windows XP.

setenv() only sets the variable within the current process and
subprocesses that process creates afterwards. setenv() *never* has
permanent results (on any operating system that uses the standard
definition of setenv())

Subject: Environment Variable Not Set by setenv command

From: Jan Simon

Date: 12 Jan, 2011 16:06:04

Message: 3 of 9

Dear Ayrangel,

> I am trying to use the setenv command to change the value of an environment variable defined in Windows XP. After using the command, if I use the getenv command I see the new value. But I still see the old value when I access the variable value thru the Control Panel or if I use the echo %varname% command on the Windows XP command prompt.

What is your actual question? And what do you want to achieve?

Kind regards, Jan

Subject: Environment Variable Not Set by setenv command

From: Ayrangel

Date: 12 Jan, 2011 16:25:07

Message: 4 of 9

"Jan Simon" wrote in message <igkjhc$7hf$1@fred.mathworks.com>...
> Dear Ayrangel,
>
> > I am trying to use the setenv command to change the value of an environment variable defined in Windows XP. After using the command, if I use the getenv command I see the new value. But I still see the old value when I access the variable value thru the Control Panel or if I use the echo %varname% command on the Windows XP command prompt.
>
> What is your actual question? And what do you want to achieve?
>
> Kind regards, Jan

The question that I forgot to ask is if there is a way to set within Matlab an environmental variable that can be used withing and outside Matlab. Thanks.

Respectfully,

Ayrangel

Subject: Environment Variable Not Set by setenv command

From: Ayrangel

Date: 12 Jan, 2011 16:26:04

Message: 5 of 9

I am too much me <roberson@hushmail.com> wrote in message <E6kXo.39986$lL1.25300@newsfe21.iad>...
> On 12/01/11 9:35 AM, Ayrangel wrote:
>
> > I am trying to use the setenv command to change the value of an
> > environment variable defined in Windows XP.
>
> setenv() only sets the variable within the current process and
> subprocesses that process creates afterwards. setenv() *never* has
> permanent results (on any operating system that uses the standard
> definition of setenv())

Thanks for the response.

Respectfully,

Ayrangel

Subject: Environment Variable Not Set by setenv command

From: Jan Simon

Date: 12 Jan, 2011 20:30:08

Message: 6 of 9

Dear Ayrangel,

> The question that I forgot to ask is if there is a way to set within Matlab an environmental variable that can be used withing and outside Matlab.

You can download the servicepack support tools for WinXP, which contain the function SETX. Then call this function through Matlab's SYSTEM command.

Kind regards, Jan

Subject: Environment Variable Not Set by setenv command

From: Ayrangel

Date: 14 Jan, 2011 12:33:04

Message: 7 of 9

"Jan Simon" wrote in message <igl30g$aov$1@fred.mathworks.com>...
> Dear Ayrangel,
>
> > The question that I forgot to ask is if there is a way to set within Matlab an environmental variable that can be used withing and outside Matlab.
>
> You can download the servicepack support tools for WinXP, which contain the function SETX. Then call this function through Matlab's SYSTEM command.
>
> Kind regards, Jan

Thanks for the feedback. I tried it, but unfortunatelly, it seems that I need administrator access to use setx to set an environment variable.

Respectfully,

Ayrángel

Subject: Environment Variable Not Set by setenv command

From: Ayrangel

Date: 14 Jan, 2011 12:51:05

Message: 8 of 9

"Ayrangel" wrote in message <igpfq0$r1a$1@fred.mathworks.com>...
> "Jan Simon" wrote in message <igl30g$aov$1@fred.mathworks.com>...
> > Dear Ayrangel,
> >
> > > The question that I forgot to ask is if there is a way to set within Matlab an environmental variable that can be used withing and outside Matlab.
> >
> > You can download the servicepack support tools for WinXP, which contain the function SETX. Then call this function through Matlab's SYSTEM command.
> >
> > Kind regards, Jan
>
Thanks a lot for the feedback! Within Matlab, the system(setx env_Var_Name env_Var_Value) worked perfectly. It allowed me to change the environment variable value and see the new value on the Windows XP Control Panel.

Respectfully,

Ayrángel

Subject: Environment Variable Not Set by setenv command

From: Jan Simon

Date: 14 Jan, 2011 12:57:05

Message: 9 of 9

Dear Ayrangel,

> I tried it, but unfortunatelly, it seems that I need administrator access to use setx to set an environment variable.

I cannot confirm this. Read e.g.:
http://technet.microsoft.com/en-us/library/cc755104%28WS.10%29.aspx

Kind regards, Jan

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us