Computer question

I have copied programs from my hard drive to a USB.
I believe that, if I somehow lose one of the programs from my hard drive, I can copy it from the USB to my hard drive and it will work.
However, I believe you can’t copy a program from one computer to another or, I assume, from my USB to a computer not my own. computer.
How come?

First of all, all these types of questions need to include the OS you are using.
But, in the general case, there is no reason why a “program” can’t be moved between drives or computers.
Howver, many software publishers (e.g. - Microsoft, Adobe) will tie a particular copy of their software to a specific machine, using a variety of “fingerprinting” techniques.
This is to reduce software piracy.

ETA: Some programs are not very self-contained, and just copying the executable to another machine isn’t enough, since the original installer wrote files in various locations on the hard drive.

A lot modern programs (in windows at least) store settings/configuration information in the registry (a massive database of settings for the computer and it’s software) and may copy some files (usually shared libraries*) to a different folder on the system (like the one specified for libraries). That’s why programs have routines for installing and uninstalling them, rather than just copying a file/folder over.

*if you’re not familiar with the concept of a libraries, they’re basically bits of code for doing common tasks (e.g. decoding a particular video or audio format) that can be used by all programs. It’s sort of like a communal toolbox.

In my experience, the best way to move a program from one computer to another is to download it again. If it doesn’t allow you to, you should contact the owner (note that most of the time you only bought a licence to use the program, not the program itself) and tell them that you are moving it, not copying it.

In general most computer programs have to be “installed” which involves writing to the registry and also involves writing bits of initialization or other files, often in obscure locations. But I have one program that I use constantly (my text editor) that all you have to do is copy its home directory and it runs right away. But that program dates back to 1984 (although it has been upgraded many times–e.g. to run in a window) with little change in functionality).

On the other hand, a different program I use constantly is totally free to download, but installation takes over an hour and involves downloading several thousand auxiliary files. Lots of luck just copying from a USB stick.

The simplest programs are just an EXE file. (Or in the good old days, COm files). However, yes, this is the issue - some programs have prerequisites. Some are written, for example, in C++ and might need the Microsoft C++ runtime installed too. Much larger windows programs use OCX controls - i.e. radio buttons, sliders, pop-up OK windows, drop-down boxes, the progress bar - these are examples of controls. A program might have its own pieces that need to be loaded. Sometimes these go into the WIN32 folder, rather than the program folder.

Some programs also need services added - programs running in the background, monitoring and maintaining things.

Things are added all over the registry - for example, a different browser like Chrome or Firefox has to modify the registry that says “if the filetype is HTML use this program to open it” etc. In the good old days, details like this and details like default locations for files, size of windows etc. were kept in an INI file. Now it’s the registry. Services need their own registry settings, plus the settings say “run me on boot”.

Short answer, many programs are too complex to simply be kept in one directory.

If you downloaded the program, you probably downloaded the installer which got put into a directory - for instance Downloads. If you can find and copy this, then reinstalling the program simply requires executing the installer, and all the changes to the registry and new directories will be created. Installers typically check for previous installations and clean up if necessary.
If you don’t know the name, you can usually go to the site where you got the program from and check the name on the download link. Then you can search for it on your hard drive.

So don’t copy the program, copy the installer.

Reported.
mmm

Looking under the help button for my browser I see the following:

(MS-Windows install. The first "…"s depend on setup and user. The second "…"s start with program name.)

For each user:
A directory containing individual settings, bookmarks, user CSS, etc. (…\AppData\Roaming…)
Another directory for cache and other temp files. (…\AppData\Local…)
One for mail. (…\Local Settings\Application Data…)

Globally:
A program directory. (…\Program Files (x86)…)
A secondary link to another browser’s plugin directory (they share them). (…\Program Files (x86)(other browser)…)

I like to copy my browser from machine to machine to preserver all my settings (esp. cookies and sites blocked). So I install the browser on the machine and then copy all of the above (except mail which I don’t use) to the corresponding directory over the new install.

This doesn’t include registry settings. There are no common lib files, etc.

Doing a search on the program name can turn up directories in various places that are used.

If you’re just doing an ad hoc backup, doing it like in the OP can help somewhat if you copy all of the right directories. But doing a real backup will be more effective.

^^^ This.

Most MacOS software would not only work fine if you copied the program back to your hard drive, it would also work fine if you double-clicked it where it sat right there on the USB drive.

All but a small subset of MacOS apps would also work in that fashion if you took that same USB drive and plugged it into a Mac that had never had that application installed. “Installing” most often consists simply of "moving the application into your /Applications folder, and it doesn’t need to be there for any reason other than having a tidy dependable location to keep your applications in.

The truth is some programs (usually the smaller ones) can be copied willy-nilly from one drive to another or one computer to another just copying and moving the folder. Other programs, usually the larger ones, usually cannot for all of the aforesaid mentioned reasons and would require a reinstall. One can find out by actually copying said program folders to another computer (a friend’s perhaps) and then you can use your personal experience personally experienced to judge.

Often programs come in a ‘portable’ version that can be run from a removable media like a USB stick. Or they can be installed as such a version. That’s what you want.

Note, of course, that a Mac “app” isn’t just a program, but an entire folder, which contains the program itself and a bunch of other files, including a number of subfolders.