Jump to content

Recommended Posts

  • Moderators
Posted (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 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!

  • Moderators
Posted (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:

Downloads.PNG

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

  • Moderators
Posted

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!

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
×
×
  • Create New...