Sign in to follow this  
Followers 0
skippynz

System Variables

10 posts in this topic

Does anyone know if there is a way to set a systemwide variable using autoit ? i know you can get the variables by useing envget but how can you set it so other programs outside of autoit can use that variable. ???

any help is appreciated.

cheers

Share this post


Link to post
Share on other sites



EnvSet()

from the helpfile:

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.


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

i know about envset() but those disappear when autoit closes. i want to use my script to set a variable that will stay when the script has finished.

Share this post


Link to post
Share on other sites

hmm would love too. but the idea is to check what type of machine is running, so that at a later date i can just pull that info out of a system variable

ie we have tecra 8100 - 9100 - m1 - m2 and m3 notebooks, each require a different setting for the power save utils. so i need to call that variable to choose what registry settings the machine will get to turn off hibernate and standby modes etc...

Share this post


Link to post
Share on other sites

guess that might just have to do if you can do system wide enviroment variables

Share this post


Link to post
Share on other sites

Does anyone know if there is a way to set a systemwide variable using autoit ? i know you can get the variables by useing envget but how can you set it so other programs outside of autoit can use that variable. ???

any help is appreciated.

cheers

<{POST_SNAPBACK}>

Write to the Registry. Try this:

RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", "XXX111YYY222ZZZ", "REG_SZ", "THIS WRITES A SYSTEM VARIABLE")

Phillip

Share this post


Link to post
Share on other sites

Does anyone know if there is a way to set a systemwide variable using autoit ? i know you can get the variables by useing envget but how can you set it so other programs outside of autoit can use that variable. ???

any help is appreciated.

cheers

<{POST_SNAPBACK}>

I haven't played with this enough to know when they become available, but to permanently, but you can write environment variables directly to the registry.

To set a USER environment variables, use:

RegWrite ( "HKEY_CURRENT_USER\Environment", "VariableName", "REG_SZ", "VariableValue" )

To set a System (global) variable, use:

RegWrite ( "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment", "VariableName", "REG_SZ", "VariableValue" )

Being a command line junkie, any system I use regularly has:

RegWrite ( "HKEY_CURRENT_USER\Environment", "Desktop", "REG_EXPAND_SZ", "%USERPROFILE%\Desktop" )
RegWrite ( "HKEY_CURRENT_USER\Environment", "MyDocs", "REG_EXPAND_SZ", "%USERPROFILE%\My Documents" )

so that from a command prompt I can type

CD %desktop%

to change to my Desktop directory, and likewise to My Documents.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Try using EnvUpdate ( )

Similar effect as logging off and then on again

I used it on my BartPe to set TARGET_ROOT so I can used the tools for ERD commander.

EnvSet("TARGET_ROOT", "C:\Windows")

EnvUpdate()

Edited by Danny35d

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

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