Inno Setup doesn't update value in [INI] - inno-setup

I'm revising script in Inno Setup Compiler 6.2.1 and got into a strange behavior.
In [INI] section I've got the following entry:
Filename: "{code:GetIniPath}\REHEV.INI"; Section: "WIDTH"; Key: "MIS_RISHUI"; \
String: "10"; Flags: createkeyifdoesntexist
When I run the installer, the log sees that file but tells that
Skipping updating the .INI file, only updating uninstall log.
However, if I change the Key to MISRISHUI (the same text but without an underscore) the update works.
How can I deal with underscore?
I've got quite a few keys like this.
Thank you!

It works for me. Underscore or not.
Isn't the problem the createkeyifdoesntexist flag? It means that if your INI file already contains the MIS_RISHUI key, it won't be updated. While if you remove the underscore, you are effectively writing a new key, which does not exist yet in the INI file.

Related

PermissionError with Inno Compiler Setup

Receiving the following error after installing my program with Inno Setup:
PermissionError[WinError 5] Access is denied: 'C:\\Program Files (x86)\\???\\temp\\\???/???'
The following line is from my File section which I believe is the issue:
[Files]
Source: "C:\Users\kirim\Documents\???\???\build\exe.win32-3.7\*"; DestDir: "{app}\exe.win32-3.7"; Permissions: users-modify; Flags: ignoreversion recursesubdirs createallsubdirs
I've tried without any permissions in that line of code, tried it with Permissions: user-modify;, and have tried it with Permissions: everyone-modify (yes I know this can create potential security issues down the road.
Also, I have seen the other post that are related to this same permissions issue and there answers are all thing's I tried as mentioned before
Kind of running out of options. Maybe, if I change the file path to relative this issue could be fixed. I've read a plethora of possible different possibilities so it's confusing. Any help would be much appreciated.
The permissions issue stemmed from writing the temp/directory to C:\Program FIles (X86)\my_project . A dependency of pywinauto writes some temp files somewhere in there, so I fixed the issue by telling the package to write to our temp directory instead. Was easily to do so because the package had a variable that I could change. Thank you for the help!

Inno Setup Compiler "Cannot find the path specified" error with long paths

I am using a .iss script to build an exe file inside Inno Setup Compiler. I need to package some node_modules into this application so I have a line under [Files] which looks like this:
Source: "{#SourcePath}Encore.Warehouse.UI\bin\Warehouse_Release\warehouse\*"; \
DestDir: "{app}\warehouse"; Flags: ignoreversion recursesubdirs createallsubdirs
When I compile, I receive this error:
Here is the compiler output:
So, it appears to be running fine up until it aborted. My initial thought was that the browser.js doesn't exist but after double checking, this is not the case. Also, I'm using a wildcard in the source path so the compiler knows the file exists, but it seems to be having trouble compressing it.
One other thing that could be causing the issue is the file path length. Node modules usually end up having ridiculous file path lengths due to nested dependencies. In this case, the path length is 260. Assuming this is what's causing the problem, is there any way to get around it?
It's definitely due to a long path. Normally Windows applications cannot process paths longer than MAX_PATH (260 characters).
See Naming Files, Paths, and Namespaces in Microsoft documentation.
A common workaround is prefixing the path with \\?\ (again see the Microsoft article above). The prefix can be used for absolute paths only. But Inno Setup compiler chokes on that with the Source attribute. It looks for : and it accepts only path that either have a drive letter only before the : or that use compiler: or userdocs: prefixes.
You can hack that by using an UNC path with a volume ID (hence no colon).
Use the mountvol command to find the UNC path for your source drive.
And then you will have the same problem with a long path with the DestDir attribute, while installing (not when compiling). There, there's no problem with the colon, so you can simply use the \\?\ prefix.
Source: "\\?\Volume{bb919c3e-bdb1-42b8-9601-6715becd8683}\{#SourcePath}Encore.Warehouse.UI\bin\Warehouse_Release\warehouse\*"; \
DestDir: "\\?\{app}\warehouse"; Flags: ignoreversion recursesubdirs createallsubdirs
Of course, if the problem is caused by a root path being too long already, you can fix the problem simply be moving the source files to a folder with a shorter path. Or you can use subst to create a virtual drive or you can create a symlink/directory junction.
Falling into the same issue, here below is more details on workaround with subst as described in comments and accepted answer.
Here below is content of some precompile.bat file to associate some local path with the A: drive letter
#echo off
REM NB: Removing any previous association to be sure new one will work
subst A: /D 1> NUL 2>&1
subst A: "%~dp0.."
And content of some postcompile.bat to remove association in the end
#echo off
subst A: /D 1> NUL 2>&1
NB1: Careful, once associated, it is difficult to navigate upper paths directly within the .iss script because A:\.. is still A:\ ! (I fall into the issue, so worth to know). Association should then be made with closest top-most folder of all required files directly in precompile.bat.
NB2: I don't know if feasible to remind for any previous association and restore it in the end
These steps can be added to the .iss script as follow:
[PreCompile]
Name: "precompile.bat"; Flags: cmdprompt redirectoutput
[PostCompile]
Name: "postcompile.bat"; Flags: cmdprompt redirectoutput
Note finally that [PreCompile] and [PostCompile] sections will execute from the IDE only. They won't execute from the command line (at least with inno 5.5.9), I also fall into this... so complete compilation from command line should look like:
call "precompile.bat"
call "%ProgramFiles(x86)%\Inno Setup 5\ISCC.exe" "myscript.iss"
call "postcompile.bat"
NB: I think calling Compil32.exe /cc "myscript.iss" (IDE compiler) instead of ISCC.exe (command-line compiler) should run [PreCompile] and [PostCompile] sections but in my case I had to pass extra /D options to the compiler so it was not possible to call Compil32.exe directly.

How to eliminate spaces for installation while writing Inno setup file?

I am creating an installer for my project where I am facing a issue.
The project is not running as expected if it is installed in the directory which contains spaces e.g: "C:\Program Files (x86)" and it is working fine if it is installed in a directory which doesn't contains spaces e.g: "C:\Python27".
So as per my understanding there is nothing wrong with project side and its all with the .iss code.
So can anyone please tell me how to solve this issue. Since most of the installers are created using Inno setup and they are installed in the program files there will be a way to solve this and which I am not aware of it.
Regards,
Bharathi
The issue is not with the spaces. My application creates a log file to log the data. Since the normal user doesn't have rights to create the file in the program files folder the application is not working... The application should be run as admin to work.
Create a symlink using mklink.
Create something like this in [RUN] section:
Filename: {cmd}; Parameters: "/c MKLINK /D {sd}\ProgramPathNoSpaces ""{pf}\Program Path With Spaces"; Flags: RunHidden;
Run your application inside the ProgramPathNoSpaces, using a shortcut with the "start in" property defined.
Hope this help you, but everyone is right. The problem is in the application, this is only a workaround.

How to save installation path to a file during installation?

My application is installed by InnoSetup.
The user may change the installation folder when he starts install the application.
I'd like to store the installation path right after the user decided about it (during the installation process), into an INI file (My application holds an INI file that is stored in the roaming folder).
Is that possible? Can you tell me how to?
Thank you
Yes, it is possible. You can simply add an [INI] section entry like this into your script. There you can pass the {app} constant, which holds the selected directory path:
[INI]
Filename: "MyProg.ini"; Section: "InstallSettings"; Key: "InstallPath"; String: "{app}"

Uninstalling files not originally installed by INNO setup

I use Inno Setup for my product's installer/uninstaller. My software has auto-update capabilities during which time it may not only change existing binaries but may also add new ones. These are additional product files that are placed into the product's installation directory - not data files.
The Inno Setup uninstaller only knows to uninstall files by name that it originally put there at install time. Since an automatic update doesn't change either the unins000.exe or unins000.dat files that make up the uninstaller, what would be the appropriate way to delete these new product files at uninstall time?
The easiest way I see is to have a batch file in your program dir that deletes all files that were added after the installation and is executed on uninstall:
[UninstallRun]
Filename: cleanup.cmd; WorkingDir: {app}; Flags: shellexec runminimized
UninstallRun commands are executed as the first step of the uninstallation, so this should work fine. If you are bothered by the idea of running a batch script, you can easily create your own cleanup.exe that deletes the files.
When you perform the auto update, you must also update the cleanup file, so that it includes all files that were added with the current update.

Resources