NSIS play with InstalldirRegKey - build

From NSIS documentation, we have
root_key subkey key_name This attribute tells the installer to
check a string in the registry, and use it for the install dir if that
string is valid. If this attribute is present, it will override the
InstallDir attribute if the registry key is valid, otherwise it will
fall back to the InstallDir default.
So, if I have these lines in a .nsi file:
InstallDir "D:\myFolder\myFile"
InstallDirRegKey HKCU "Software\${PRODUCT_COMPANY}\${PRODUCT_NAME}" "Install_Dir"
I understand that I set my install directory to D:\myFolder\myFile as default directory, but if Software\${PRODUCT_COMPANY}\${PRODUCT_NAME} is a valid path, then I will use it instead. Is that correct?
From another post, I understand that the InstallDirRegKey instruction is used to overwrite previous installation at same location. How is it working more precisely? If I have the following,
InstallDir "D:\myFolder\myFile"
InstallDirRegKey HKCU "D:\myFolder\myFile" "Install_Dir"
will a new .exe file generated by the NSIS script overwrite the previous one? Or does it mean that the executable will overwrite the previous one?

InstallDirRegKey only reads from the registry, it never writes.
Before your .onInit is executed NSIS does:
If InstallDir is set, that path is copied to $Instdir
If InstallDirRegKey is set and the registry key exists, the path from the registry (With the filename removed) is copied to $Instdir
So if you want InstallDirRegKey to have any effect the next time a user runs the installer you must point it to a key that your installer creates in one of your sections. It can be the UninstallString command in your uninstall key or a application specific key like HKLM\Software\My Company\My App.
The whole point of this is that when the user re-installs or installs a new version of your app it will be installed in the same folder (overwriting/upgrading the existing install).

Related

Making File and Folders Hidden in Install4j and replace installer variable action related query

Is there is any way to make files/folders hidden during or install files action in install4j.
Like similar to .install4j folder in Installation folder.I am working on CentOS platform.
When install4j action replaces installer variables in files those are replaced as it is in text format,is there is any way to replace encrypted values or hide those replaced variables in shell script as it might contain sensitive information.
As of install4j 8, there is no action to make files hidden
Call context.registerHiddenVariable("<variable name>") in a script to tell install4j that an installer variable contains sensitive information. Its contents will not be written to the log file.

file path of '/tmp' in Django Session

Right now i am using file based session in django to save data.
SESSION_ENGINE = "django.contrib.sessions.backends.file"
As per documentation django saves data in /tmp, but i dont understand what is actual path of this /tmp! Is this a directory in my project or else where?
I think you misread the documentation, the documentation [Django-doc] says:
You might also want to set the SESSION_FILE_PATH setting (which defaults to output from tempfile.gettempdir(), most likely /tmp) to control where Django stores session files. Be sure to check that your Web server has permissions to read and write to this location.
If we check the documentation on the tempfile.gettempdir() [Python-doc] we get:
Return the name of the directory used for temporary files. This
defines the default value for the dir argument to all functions in
this module.
Python searches a standard list of directories to find one which the
calling user can create files in. The list is:
The directory named by the TMPDIR environment variable.
The directory named by the TEMP environment variable.
The directory named by the TMP environment variable.
A platform-specific location:
On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order.
On all other platforms, the directories /tmp, /var/tmp, and /usr/tmp, in that order.
As a last resort, the current working directory.
The result of this search is cached, see the description of tempdir
below.
So althought on Unix-based systems (Linux, BSD, Mac OS X, etc.) it will be stored in /tmp, it depends on the operating system.
As for Unix-based file systems, if there is a slash (/) in the front, that means an absolute path, so it is the tmp directory in the root of the filesystem. For more information on Unix file paths, see this article [geeksforgeeks].
If you however set the SESSION_FILE_PATH to a specific path, then that path will be used.
Note that temporary files are, well, temporary. Typically you should not assume that after a reboot, the files are still there.

set the OpenSSL_HOME variable

I am trying to configuring HTTPS based on this tutorial:
Configuring HTTPS for your Elastic Beanstalk Environment
I am stuck at the following section:
To set the OpenSSL_HOME variable
Enter the path to the OpenSSL installation:
c:\ set OpenSSL_HOME=path_to_your_OpenSSL_installation
My openSSL is installed in c:\OpenSSL, so would I write set OpenSSL_HOME=C:\ OpenSSL?
Do I enter such command in Command Prompt?
Finally this step:
To include OpenSSL in your path
Open a terminal or command interface and enter the appropriate command for your operating system:
c:\ set Path=OpenSSL_HOME\bin;%Path%
My %Path% here would be what?
My openSSL is installed in c:\OpenSSL, so would I write set OpenSSL_HOME=C:\ OpenSSL?
Yes, but without the space after C:\:
set OpenSSL_HOME=C:\OpenSSL
Do I enter such command in Command Prompt?
You can. Do note, however, that with this approach, you would be modifying the OpenSSL_HOME environment variable for that particular command window only, and it would be accessible only to processes that are run from that same window. As soon as you close the window, your variable disappears.
If you need to make it persistent, especially through reboots, you have to configure the OS's global environment instead. On Windows, right-click on My Computer, go to Properties, Advanced system settings, Environment Variables, and add a new entry for your variable.
My %Path% here would be what?
That is an existing environment variable. You are modifying the existing Path, so by including %Path% to the end of your assignment, you preserve the existing Path so that existing paths can still be accessed.
Fir, note that the example in the documentation is wrong. It should be this instead:
c:\ set Path=%OpenSSL_HOME%\bin;%Path%
With that said, lets say for example that Path already contains a value of C:\Windows\;etc. After the assignment, the new Path will be C:\OpenSSL\bin;C:\Windows\;etc

what is the proper method of using resource files in MFC project?

i have made a MFC-based game and my project includes images and sounds. Now i want to create an installer setup in order to distribute it.
i have used the resources by providing their exact path in e.g
img->Load(L"C:\\Users\\Ad33l's\\Desktop\\block mania\\block mania\\res\\db.png");
MCIWndCreate(NULL, NULL,WS_POPUP|MCIWNDF_NOPLAYBAR|MCIWNDF_NOMENU,L"C:\\Users\\Ad33l's\\Desktop\\block mania\\block mania\\res\\tick.wav");
1.Can someone tell me any way to avoid Hard-coding the actual resource path as these resource files will not be present at this same exact path in other computers ?
2.Also guide me to handle these resource files during the creation of standalone SETUP (i am using advance installer )
(as an actual answer).
Do not use absolute path, always use relative path; relative to your EXE file is one solution.
The EXE path can be found using GetModuleFileName.
char appPath[MAXFILENAMELEN];
GetModuleFileName(NULL, appPath, MAXFILENAMELEN);
(addendum) appPath name is misleading, it contains the full name of the application; you need to extract the path from the full application name.
We do something like this:
(edit to make it compilable in unicode)
TCHAR applicationPath[MAX_PATH];
GetModuleFileName(NULL, applicationPath, MAX_PATH);
CString sSoundFile(applicationPath);
PathRemoveFileSpec(sSoundFile.GetBuffer());
sSoundFile.ReleaseBuffer();
From there, you can do something like (pseudocode-ish):
img.Load( appPath + "//Images//db.png" );
You can have a variable that saves the directory they want to install your program in. After they choose the directory they want to install it in, go off of that. Or you can also use system folders like the appdata folder
A first solution would be to configure your setup project to install the installation files under the DesktopFolder\block mania\block mania\res. Then, you can access within your application the current user Desktop location and append to it the remaining fix location (block mania\block mania\res).
Another solution would be to configure the setup project to create registries at install time which will store the paths of the installation files. Then, your application could read the installation paths from registry.
Finally you could also create at install time environment variables containing the paths of the installation file and, then use within your application the environment variables to access the installed files locations.

Can fossil reserve executable mode on my shell script?

I use fossil to keep my shell script. But If I check in it and use it cross Windows & Linux, then the executable permission is missing of my shell script. How to add it back like svn's property setting?
As documented here. A manifest F-card (a file that's part of the check in) has up to four arguments. The (optional) third argument defines special access permissions associated with the file. If the letter 'x' is specified on this third argument then the file is defined as executable. Try setting the permissions of the file to executable:
chmod u+x,g+x,o+x myscript.sh
Then check the script in (you may have to modify it a bit, add a comment etc..). The script should be saved with it's executable bit sent in it's F-card entry the manifest. When it's checked out (on Linux) the executable bit should be set. Try not to modify and check-in the scripts on Windows or other file system that doesn't support Unix permissions.