TristanPittman Posted September 24, 2007 Share Posted September 24, 2007 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 More sharing options...
weaponx Posted September 24, 2007 Share Posted September 24, 2007 (edited) 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 September 24, 2007 by weaponx Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted September 24, 2007 Moderators Share Posted September 24, 2007 There are AutoIt Macros that cover what you are wanting. @StartMenuCommonDir - path to Start Menu folder @StartMenuDir - path to current user's Start Menu @DesktopCommonDir - path to Desktop Link to comment Share on other sites More sharing options...
Developers Jos Posted September 24, 2007 Developers Share Posted September 24, 2007 Or use: Opt("ExpandEnvStrings", 1) SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SadBunny Posted September 24, 2007 Share Posted September 24, 2007 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 More sharing options...
vnavna Posted October 22, 2007 Share Posted October 22, 2007 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 More sharing options...
evilertoaster Posted October 22, 2007 Share Posted October 22, 2007 the syntax would be If Not FileExists(@UserProfileDir & "\office 2007") Then DirCreate(@UserProfileDir & "\office 2007") EndIf Link to comment Share on other sites More sharing options...
Blue_Drache Posted October 22, 2007 Share Posted October 22, 2007 Damn you toaster....you popped up your eviler head before I could finish my post!! *shakes fist* Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
weaponx Posted October 22, 2007 Share Posted October 22, 2007 Yet another zombie thread. The only way to stop it now is by removing the head or destroying the brain. Link to comment Share on other sites More sharing options...
vnavna Posted October 22, 2007 Share Posted October 22, 2007 Thanks a lot. It works great. Is there anywhere else to learn about how to use some of these autoit commands? Due to the fact that the help file is really vague. Link to comment Share on other sites More sharing options...
weaponx Posted October 22, 2007 Share Posted October 22, 2007 I think the help file is quite comprehensive. It is the only means of reference other than this forum if thats what you're asking.We are still waiting on AutoIt: For Dummies! to show up at Staples but meanwhile you can look into AutoIt 1-2-3:http://www.autoitscript.com/forum/index.php?showtopic=21048# Link to comment Share on other sites More sharing options...
xcal Posted October 22, 2007 Share Posted October 22, 2007 Thanks a lot. It works great. Is there anywhere else to learn about how to use some of these autoit commands? Due to the fact that the help file is really vague.Vague? You've got to be kidding. Every function has an example, it's all indexed, and there's a perfectly good search. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
vnavna Posted October 22, 2007 Share Posted October 22, 2007 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 More sharing options...
Blue_Drache Posted October 22, 2007 Share Posted October 22, 2007 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now