0

On Ubuntu, the default path includes /usr/bin, which is where most system applications are installed via sudo. The equivalent on Windows is C:\Program Files, protected by UAC. (Of course, it's more complicated than that.)

On Ubuntu, the default path also include ~/.local/bin (kinda), which is where you can drop user applications, for example a Python script you can invoke from anywhere. sudo is not required in any part of the process.

Is there an equivalent to ~/.local/bin on Windows? A user folder already on the path where you could drop an EXE, open the terminal, navigate to any folder, and invoke the EXE, all without triggering UAC. Alternatively, is there a de facto convention?

lofidevops
  • 1,308
  • 4
  • 18
  • 41
  • Although the question is worded differently, the answer is [What exactly is “C:\Users\MyUser\AppData\Local\Programs”?](https://superuser.com/questions/1482669/what-exactly-is-c-users-myuser-appdata-local-programs) Although you would need to add the path to the PATH environment variable. – Andrew Morton Apr 13 '23 at 16:22
  • It's not at all, they're entirely different questions. This would be much closer duplicates: https://superuser.com/questions/675333/why-is-there-no-usr-bin-in-windows https://superuser.com/questions/1518052/bin-folder-for-windows-10 Although one has "why" and another is messy and more focoused around Python. – Destroy666 Apr 13 '23 at 16:38
  • Plus of course they're more focused around the "global" dir. But at least they mention `PATH` which is the main point of this question, IMO. – Destroy666 Apr 13 '23 at 16:47
  • @lofidevops Do you want a location which only the current user can access (by default), or a location which all users can access (by default)? – Andrew Morton Apr 13 '23 at 16:48
  • @AndrewMorton just the current user without triggering UAC; I'll update the question to mention sudo/UAC – lofidevops Apr 13 '23 at 17:55

3 Answers3

1

I don't think that there is an exact equivalent to Ubuntu's ~/.local/bin on Windows. However, you can achieve somewhat the same effect by creating a folder for your scripts and executables and adding it to the PATH environment variable.

I do this on my Windows machines:

  • I create a folder for my scripts like C:\Users\<Username>\scripts
  • Then I go to Environment Variables and add the above folder to the PATH variable

Now, I can put my scripts in the above folder, and they will be accessible from the command prompt regardless of the current working directory. This method essentially creates a user-level PATH entry similar to ~/.local/bin on Ubuntu.

Bilesh Ganguly
  • 829
  • 1
  • 6
  • 16
  • 1
    Nice answer. And to take this to the next level, if you modify the PATHEXT variable, you can even make the scripts (and other things) executable without using the extension. This even works with .LNK (shortcut) files. For instance.. if you add ;.PY;.LNK, you can now run these files without using the extension. There is a small security risk with doing this but I choose to take that risk. – Señor CMasMas Apr 13 '23 at 16:11
0

Do not try to match the directory/folder systems of Windows and Linux. They are so different so you can hardly find anything to compare.

Moreover you rarely need to exec something from command line because most of the things have "shortcuts" in start menu.

I personally use: c:\tools and add it in to the PATH.

Romeo Ninov
  • 5,319
  • 5
  • 20
  • 20
0

No, there isn't one. You can freely create one by editing environment variables and adding any directory to the PATH var. E.g. people recommend C:\tools for some reason, I personally think it's a bit messy location. User-based it would be e.g. C:\Users\[user]\Tools or any other directory that you choose inside the [user] folder.

Also, if you install Chocolatey package manager then that includes a similar folder where all executables that should be in PATH are stored by shimming: C:\ProgramData\chocolatey\bin

I would strongly recommend going for that approach, it saves a lot of time, although scripts for some apps (like Ghostscript) don't do shimming. I'd say ~95% of executables that I'd want to be in PATH are handled properly. Plus of course you get the regular advantages of a package manager.

Destroy666
  • 5,299
  • 7
  • 16
  • 35
  • Can you clarify why `%LocalAppData%\Programs` is not the same thing? Installers often ask if the install is for all users or just the current user. – Andrew Morton Apr 13 '23 at 18:22
  • How is it the same thing and how is it different than e.g. `%LocalAppData%` itself? Some apps install to that directly. `bin`, as the name suggests, is for **binaries**, not installs. Both `Program Files` and `Programs` are incorrect comparisons in terms of functionality, they're not even "flat" structure. – Destroy666 Apr 13 '23 at 18:36