Sign in to follow this  
Followers 0
random8011

Envset

8 posts in this topic

#1 ·  Posted (edited)

PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem

I want to make the path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\oracle

how can i do?

my script:

$oldpath = EnvGet("PATH")

$newpath = "$oldpath"&";c:\oracle"

EnvSet("PATH", $newpath)

EnvUpdate()

it seems no use

help me ,thanks

Edited by random8011

Share this post


Link to post
Share on other sites



else ..

EnvSet("Path", "this is a test")

Why It seems take no effect???

how can i change my system's Evn Path???

Share this post


Link to post
Share on other sites

Do you read the Bold part? Or really you have no effect?

A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist.

Share this post


Link to post
Share on other sites

SETX is the most easy solution.

Share this post


Link to post
Share on other sites

SETX is the most easy solution.

<{POST_SNAPBACK}>

i have just seen the problem

about setx,what should i do?i really don't know,,plz give me a little tips,thanks

Share this post


Link to post
Share on other sites

Hello random8011,

if your problem is what ezzetabi wrote in the bold part (" Once AutoIt closes, the variables will cease to exist.") and you don´t want to use setx, just AutoIt, you can try this small function I wrote a while ago for my loginscripts:

Func setuserenv ($nameandvalue)
   $name=stringmid($nameandvalue,1,StringInStr ( $nameandvalue, "=",1)-1)
   $value=stringmid($nameandvalue,StringInStr ( $nameandvalue, "=",1)+1,256)
   RegWrite("HKEY_CURRENT_USER\Environment", $name, "REG_EXPAND_SZ", $value)
   EnvUpdate ( )
EndFunc

Usage is like that (example):

setuserenv ("PATH=C:\TEST")

Note the function only sets enviroment for the current user. (Should be fine most of the time + in this case you don´t need adminrights to use the function).

I only tested it on german WinXP and Win2000 systems but I don´t see any reason why it should not work on other language system, too. So you might give it a try if you like.

commenti

Share this post


Link to post
Share on other sites

to commenti ,

it's so kind of u.

your code make me know the very interesting "Func" function in autoit.

i will try it ,thanks a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0