TheAutomator Posted March 30, 2017 Posted March 30, 2017 How can you get the downloads folder in AutoIT? As far as i know there isn't a macro for it right? like @Downloads or something? The ugly solution would be typing in the whole path but what if the user has chosen another location? Need to clear that folder regularly on my work and on different accounts.. regards, TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone
Moderators JLogan3o13 Posted March 30, 2017 Moderators Posted March 30, 2017 (edited) Like so: ShellExecute(@UserProfileDir & "\Downloads") edit, I missed your "User has chosen another location". Typically I would say look at EnvGet, but don't think the Downloads folder is set as a typical environment variable. There is DEFAULT_DOWNLOADS, but that is for the default profile. Edited March 30, 2017 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
TheAutomator Posted March 30, 2017 Author Posted March 30, 2017 (edited) Hi JLogan3o13 Thanks for the quick reply. I'm just thinking out loud here: Imagine: the user has set the downloads folder path on the desktop or something? [EDIT] Oh i see, hmm.. small but tricky problem huh Edited March 30, 2017 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone
Moderators JLogan3o13 Posted March 30, 2017 Moderators Posted March 30, 2017 (edited) I know that if you change the path (and only if you change the path) it will show up in HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders, but it shows up as a GUID, like so: You could search for that, but would have to either load the user's registry hive or run it as them (startup script). And I believe several other folders, when changed, produce a similarly encoded name, so not sure how you would distinguish that {374DE290-...} is the new target for the Downloads folder and not something else. If the user goes so far as to redirect one folder, they may do so for others. Edited March 30, 2017 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
TheAutomator Posted March 30, 2017 Author Posted March 30, 2017 Well, i guess i have to stick with the ugly solution then.. or do something like if fileexists()... Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone
Moderators JLogan3o13 Posted March 30, 2017 Moderators Posted March 30, 2017 Yes, it could be ugly either way. You could do a fileExists, but unfortunately it won't tell you where the folder has been redirected. You would have to do something like this (pseudo): If Not (FileExists(@UserProfileDir & "\Downloads")) Then For $a = 1 To 100 $sVal = RegEnumVal("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders", $a) If @error Then ExitLoop Else If StringInStr($sVal, "{374DE290-") Then ;further processing EndIf EndIf Next EndIf Even if you stick with the "ugly" C:\Users\TheAutomator\Downloads, if the user has moved the target you're sunk. Good luck with your project. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Bowmore Posted March 30, 2017 Posted March 30, 2017 This link has a lot of information about special folders, their GUIDs and default locations etc. https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook
Moderators JLogan3o13 Posted March 30, 2017 Moderators Posted March 30, 2017 So according to that page the GUID is static, after all. That should make things slightly easier for you, should you go that route, @TheAutomator "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
AspirinJunkie Posted March 31, 2017 Posted March 31, 2017 #include <WinAPIShellEx.au3> $s_Path_Downloads = _WinAPI_ShellGetKnownFolderPath($FOLDERID_Downloads) MsgBox(0,"", $s_Path_Downloads) AdamUL and maniootek 2
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