Jump to content

Varables


Recommended Posts

So you want something like %ALLUSERSPROFILE% that the OS may offer? I do not see a macro for that one.

To know available Environmental Variables for your OS, then just type Set and press Enter at a command prompt to display all available Environmental Variables. To use an Environmental Variable in an AutoIt script, you can use EnvGet() to evaluate the string representation of the Environmental Variable name and get the value.

Example:

Global Const $ALLUSERSPROFILE = EnvGet('ALLUSERSPROFILE')
MsgBox(0x40000, 'ALLUSERSPROFILE', $ALLUSERSPROFILE)
Link to comment
Share on other sites

So you want something like %ALLUSERSPROFILE% that the OS may offer? I do not see a macro for that one.

Yet another way to do it:
; Default setting
Opt("ExpandEnvStrings", 0)
ConsoleWrite("All Users dir = %ALLUSERSPROFILE%" & @LF)

; How to get the environment variable with the default setting
ConsoleWrite("All Users dir = " & EnvGet("ALLUSERSPROFILE") & @LF & @LF)

; Changed setting
Opt("ExpandEnvStrings", 1)
ConsoleWrite("All Users dir = %ALLUSERSPROFILE%" & @LF)

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...