Jump to content

Envset


Recommended Posts

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
Link to comment
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.

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...