Jump to content

How do you refer to Microsoft environment variables in an Autoit script?


Recommended Posts

How do you refer to Microsoft environment variables in an Autoit script?

I'm stuck. I do not understand how to use a Microsoft environment variable such as %UserProfile%, %AllUSersProfile%, %AppData%, in an Autoit script. This must be a dumb question but I'm new to Autoit and programming.

I need to close two windows opened by an installer, is this proper syntax?

WinClose ("%UserProfile%\Start Menu\Programs\open folder", "")

WinClose ("%AllUSersProfile%\Start Menu\Programs\open folder", "")

I would like to copy folders to the following location, is this proper syntax?

DirCopy ( "I:\install files", "%AllUSersProfile%\desktop", 1)

Link to comment
Share on other sites

Check out the Macro Reference in the help file.

Macros for "All User" data. Most values are read from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

@AppDataCommonDir path to Application Data

@DesktopCommonDir path to Desktop

@DocumentsCommonDir path to Documents

@FavoritesCommonDir path to Favorites

@ProgramsCommonDir path to Start Menu's Programs folder

@StartMenuCommonDir path to Start Menu folder

@StartupCommonDir path to Startup folder

Macros for Current User data. Most values are read from HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion

@AppDataDir path to current user's Application Data

@DesktopDir path to current user's Desktop

@MyDocumentsDir path to My Documents target

@FavoritesDir path to current user's Favorites

@ProgramsDir path to current user's Programs (folder on Start Menu)

@StartMenuDir path to current user's Start Menu

@StartupDir current user's Startup folder

@UserProfileDir Path to current user's Profile folder.

Edited by weaponx
Link to comment
Share on other sites

Furthermore, there is EnvGet() to retrieve actual environment variables for when you need something that is not covered by the AutoIt macros.

Also: you can just close a window by doing WinClose() with the title of the window (or with a part of it). Your approach might be the long way around.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

  • 4 weeks later...

I am trying to do the same thing by switching from a batch file to autoit. i would like to convert the following batch file

If Exist "%USERPROFILE%\office 2007" GOTO END

MD "%USERPROFILE%\office 2007"

:end

I used this

If Not FileExists("%USERPROFILE%\office 2007") Then

DirCreate("%USERPROFILE%\office 2007")

EndIf

It will not create the directory if it does not exist. How do I use @UserProfileDir to fix this?

Link to comment
Share on other sites

There is a lot of examples on most of the topics. But for the last search with @UserProfileDir it showed nothing for an example. I do not like coming in here asking for help all of the time. It makes me feel that the questions that I am asking are so simple to figure out but I just can't do it. I just don't like waisting your time for these simple answers.

Link to comment
Share on other sites

what part of

Macros for Current User data. Most values are read from HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion

@AppDataDir path to current user's Application Data

@DesktopDir path to current user's Desktop

@MyDocumentsDir path to My Documents target

@FavoritesDir path to current user's Favorites

@ProgramsDir path to current user's Programs (folder on Start Menu)

@StartMenuDir path to current user's Start Menu

@StartupDir current user's Startup folder

@UserProfileDir Path to current user's Profile folder.

Don't you understand? It's in clear english!

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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...