How to do string replacement in nsis? - nsis

I want to do string replacement in NSIS for following string:
C:/Program Files (86) replaced into C:/Program Files.
I have searched and got this link for string replacement.
From that link i need to include whole functions. It may maximize the coding. Is there any built-in functions is there or any other way is possible?

NSIS only has 3 basic string instructions: StrCpy, StrLen and StrCmp. Everything else is built on top of that with macros and functions...
Transforming "Program Files (86)" to something else is not a good idea, the Program Files folder could have a different name (On my system it is called Applications)! Use $ProgramFiles32 or $ProgramFiles64 to get the directory you want...

Related

Add file after generating the installer executable

I would if we can add some files(text or executable) to a NSIS installer with a tool(or not) after the package is done.
Thank you for your help
You cannot really append extra files after the compiler has finished. You can however append a small text string if you need to embed some sort of id/hash/serial number. This data can be read with the ReadCustomerData function from the NSIS wiki.
You can compile installers on Windows and POSIX based systems so you can build installers anywhere if you absolutely need to add a file that does not exist on your system...

How to make own language file in NSIS?

I want to make my own language file for my installer. I want to make my installer which will support two languages "English" and "Hindi". But there is no language file for hindi. So I want to make my own language file for hindi. Can anyone tell me how to make it and how to link it with NSIS? And what is ".nlf" files e.g "English.nlf" present in the NSIS Contrib folder?
The .nlf files inside Contrib\Language files are storing all default dialogs used by NSIS. The .nsh files in the same folder are used by installers with Modern UI. I'd clone the files for English translation (or any other language you prefer as starting point) and change all the strings inside.
For your convenience, there are packages available for Sublime Text and Atom, that let you jump between each translation field.
As suggested by idleberg, you just copy one of the .nlf and .nsh files and translate the strings but you are in luck, the NSIS fork already has a almost complete translation.

How can I detect the names of files in a folder in Visual C++?

I have a folder that is containing text files (.txt). In my application I must read all files from this folder. But I don't know the names of these files and how many files in the folder. My application is C++ console application in MS VS 2013 without MFC support and without BOOST. Is there any function in Visual C++ that allows to detect the names of the files placed in specified folder and returns these file names? For example the name of the folder is SomeFolder. I'll be very much obliged to you for help.
There are multiple ways of enumerating files within a folder such as WinAPI32 (FindFirstFile & FindNextFile) or MFC (CFileFind class).
The following are examples of either way:
How to get list of files in a directory programatically
Recursive file search using C++ MFC?

SublimeText3 - Find all files without a string?

I've looked around quite a bit for an answer to this, but I cannot seem to find what I need. Is it possible with SublimeText3 > Find in Files to do a search for all files that DO NOT include a string?
I've tried toggling the Regular Expressions button beside "Find:" and entering a value, but I'm not a regex pro, so I may be doing it wrong?
For example, I want to find all files in a designated folder that DO NOT have the following string:
social-links
Any help would be greatly appreciated.
Search for all files in your directory in question (for anything, like a space or the letter e...assuming every file has a space or letter e!), and copy all those file-paths to a new file.
Search for all files with the word, and paste that path-list into a second file.
Sort both files, then compare them to see which lines--which paths--are missing from the has-the-word file. Those are the ones you want.
As far as a single find-in-files search, I don't see how you would do that in Sublime or any other basic text editor. Here is some more information:
https://unix.stackexchange.com/questions/26836/how-can-i-find-all-files-that-do-not-contain-a-text-string
Find files that does not contain a string
How to find all files that do NOT contain specific string in windows environment Visual Studio or any other IDE?
Good luck!

NSIS: How to check whether *.dll from my installation is in $SYSDIR?

I wanted to write an NSIS script, let's call it for now setup.nsi, and check
if several required dll files already exists in $SYSDIR
Let me emphasize on the word "several"
What I understand from nsis IfFileExists documentation is that if I type in:
IfFileExists $SYSDIR\blabla.dll +2 +1
then it checks if blabla.dll is in $SYSDIR .. but what if I want to know if *.dll from where setup.nsi copies the file (i.e. the *.dll's that I am interested in installing in.. and they are a lot of them.. so I can't just go around checking for all the names) exists in $SYSDIR
During uninstallation I want to then be able to delete them from $SYSDIR (using some uninstall.log to see if I really copied them in $SYSDIR.. and again the wildcard question).
Please be patient with me as I am really new to NSIS scripts.
Is it REALLY necessary to write and delete in $SYSDIR ? Unless yours is a system file, there's no reason for it to be in $__SYS__DIR. If you need to use a specific version of a library, consider DLL redirection (put your DLL in your app dir and use the .local feature) - see the MSDN article on DLL redirection and Side-by-side assemblies.
Plus, you are one typo away from wrecking the user's computer ("Deleted: C:\Windows\System32\user32.dll").
As Piskvor mentions, I don't think you should be worrying about deleting system DLLs in the uninstaller. In case you want to overwrite system DLLs with an updated version, you may want to look at the SetOverwrite command. It lets you overwrite files if what you've got is newer.
Windows XP (SP2?) and up has file protection for system32, so you can't overwrite system critical files in there.
Do try to stay away from that.
Also, to check for your file specifically, see if there's a plugin for NSIS that can calculate checksums and compare that on uninstall. That's probably the safest, IF you really need to do it.
I'd suggest install files somewhere else and add that to PATH.

Resources