Add environment path management for installation#4514
Add environment path management for installation#4514eduardomozart wants to merge 6 commits intotesseract-ocr:mainfrom
Conversation
|
Due to limitations of the possible PATH length for Windows and undefined behaviour when the PATH length reaches the limit, this feature is not desired. Personally I also don't like lengthy parts which affect all running software and can produce unexpected side effects. It would also make parallel installations of different Tesseract versions more error prone. |
|
Setting PATH was removed more than 10 years ago in commit c886e3b because it resulted in an empty PATH (!) if the old PATH was very long. This problem was reported in issue #481. @eduardomozart, can you confirm that we won't re-introduce this old problem with your pull request? |
|
I can definitively confirm that this PR will not re-introduce the issue from #481. The bug from 10 years ago was caused by native NSIS registry commands ( By using the EnVar plugin, we bypass this native NSIS limitation entirely. EnVar uses the Windows API directly to safely read and append to environment variables regardless of their length. To be absolutely certain, I tested this locally. I intentionally bloated my
The installer handled it perfectly and appended |
|
It looks like the new UI texts with translations are still missing. |
There was a problem hiding this comment.
Pull request overview
This PR adds automatic PATH environment variable management to the Tesseract Windows installer, allowing users to run tesseract.exe from any command prompt without manual configuration. The implementation adds an optional installer section with privilege-aware logic to modify either system (HKLM) or user (HKCU) PATH, and includes corresponding cleanup in the uninstaller.
Changes:
- Added optional "Add to PATH environment variable" installer section with privilege checking
- Implemented automatic PATH removal during uninstallation
- Added command-line flag
/ADDENVPATHfor automated/silent installations
…ion) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Added functionality to manage environment PATH for Tesseract installation.

Description
This PR enhances the Windows installer by automatically adding the Tesseract installation directory to the system or user
PATHenvironment variable. This allows users and automated scripts to runtesseract.exefrom any command prompt immediately after installation without manual configuration.Motivation
Standardizing the
PATHconfiguration during installation improves the out-of-the-box experience and simplifies automated, unattended infrastructure deployments. Previously, users had to manually edit their environment variables after installing.Key Changes
$MultiUser.InstallModeand the actual account privileges (UserInfo::GetAccountType). It safely writes toHKLMif running as an Administrator (All Users) or falls back toHKCUfor standard users (Current User).EnVarplugin to modify thePATH. This is highly recommended over native NSIS registry commands to avoid truncating existingPATHstrings that exceed 1024 characters.PATH.Notes for Reviewers
tesseract.nsinow requires the EnVar plugin to be present in the NSIS plugins directory.