This should be impossible, as the user can always make a copy of the installation package before starting it. A package (for example, a * .msi file) is just a sequence of bytes that can be copied ...
You can limit it to 2 installations per machine, given that you leave some information somewhere (for example, in the registry).
Another alternative is to have a license key (or a key embedded in the installation package), which is then used to activate the software using a central server on the Internet. This is probably just an option.
source share