environment variables

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
totmad1
Posts: 131
Joined: 24 Jun 2013 12:37

environment variables

Post 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.
totmad1 (totally mad one)

highend
Posts: 14662
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: environment variables

Post 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 ;)
One of my scripts helped you out? Please donate via Paypal

FluxTorpedoe
Posts: 904
Joined: 05 Oct 2011 13:15

Re: environment variables

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

rebr
Posts: 41
Joined: 17 Nov 2013 20:30

Re: environment variables

Post 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:

admin
Site Admin
Posts: 65345
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: environment variables

Post by admin »

Not bad! :tup:

PeterH
Posts: 2826
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: environment variables

Post 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:

Post Reply