Page 1 of 1

environment variables

Posted: 17 Oct 2014 21:41
by totmad1
A new forum member P.M'd me concerning how to go to downloads folder.
I searched the forum and found no help.
There is of course a short paragraph in the help file pointing to Help | Environment Variable.s
To shorten this if you type in AB :- %USERPROFILE%\downloads
This will work with pictures,videos etc. folders.

Re: environment variables

Posted: 17 Oct 2014 22:05
by highend
This must not be true for all those people who transfer their personal folders to a different partition using the supported method for it (which is a recommended way to separate your data from your system partition to make backups / images creation more foolproof).

- Open windows explorer
- Go to %USERPROFILE%
- Right click e.g. the Downloads folder, choose "Properties"
- Go to the "Location" tab
- Click on "Find target..."
- Navigate to the folder that will be your new download folder
- Click on "Apply"

You get a security question if you really want to move all data to the new folder, click "Yes"

But when you now navigate to your download folder by using the suggested method, you'll will not land in the "correct" place...

The real path for the moved (and the original location if not moved) download folder can be found in the registry:

Code: Select all

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
{374DE290-123F-4565-9164-39C4925E467B}
This entry always reflects the correct location.

Just my two cents ;)

Re: environment variables

Posted: 18 Oct 2014 08:57
by FluxTorpedoe
As a small addendum, for a portable use of XYplorer, I use this in one of my menus:

Code: Select all

  if exists("%personalreal%\downloads") {
    goto "%personalreal%\downloads";
  } else {
    goto "%userprofile%\Downloads";
  }
AFAI've seen, it works under WinXP, Win7 and Win8 (provided the default locations haven't been changed as highend pointed out).

Re: environment variables

Posted: 21 Sep 2016 01:56
by rebr
Hi everyone!

Just to place here a script I made to my need, with the ideas and help of highend and FluxTorpedoe.

Code: Select all

function _FolderDownloads() {
  if (exists("%personalreal%\downloads\")) { $x = "%personalreal%\downloads\"; }
  elseif (exists("%userprofile%\downloads\")) { $x = "%userprofile%\downloads\"; }
  else {
    $k = quote("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders");
    $v = quote("{374DE290-123F-4565-9164-39C4925E467B}");
    $x = formatlist(gettoken(runret("REG QUERY $k /v $v"), 4, "    "), "e", <crlf>);
  }
  $x = (substr($x, -1) == "\")?$x:$x . "\";
  return $x;
}
I think it's working nice.

A special thanks to you 2. :beer: :tup:

Re: environment variables

Posted: 21 Sep 2016 09:18
by admin
Not bad! :tup:

Re: environment variables

Posted: 21 Sep 2016 11:36
by PeterH
Not bad :tup:

Just to say:
$x . "\"
is identical to
"$x\"
(as long as the 1st letter behind the var name isn't alphabetical or numeric, i.e. can't be misinterpreted as part of the var name)

For better readability I'd surround ? and : by blanks - my old eyes first had some problems to recognize this expression :oops: