How to copy folder from within a zip using NSIS? - zip

I'm using NSIS to write an installer. I'd like to copy the 'lib' directory contained in a zip. Is it possible to specify that the contents of sampleZip.zip/lib is copied to, say $INSTDIR\lib?
The basic idea of what I want is this, though it obviously doesn't work:
File /r sampleZip.zip\lib\*
Any ideas on how this can be done?

NSIS does not have native support for this, you need to use one of the unzip plugins: NsUnzip, Nsisunz or ZipDLL

Rather than install the plugin, I just copied the libraries I needed using the plugin described at this answer force Maven2 to copy dependencies into target/lib.
Since I was the one building the zip file I wanted to access, I felt this way would be more reliable.
Thanks for the suggestions.

Related

syntax highlight (.tmLanguage) in Sublime Text 3 for packages

I work on this plugin
Syntax highlight does not work with Sublime Text 3 when plugin is installed using package control.
Error loading syntax file "Sublime Text 3/Installed Packages/robot.tmLanguage": Unable to open Sublime Text 3/Installed Packages/robot.tmLanguage
The plugin is under Installed Packcages/Robot Framework Assistant.sublime-package, the file 'robot.tmLanguage' in inside Robot Framework Assistant.sublime-package archive.
Here is how I set paths
https://github.com/andriyko/sublime-robot-framework-assistant/blob/master/rfassistant/init.py
My question is similar to this thread, but in my case the plugin is installed as archive(.sublime-package) not folder with with files.
I am not sure that my path settings mentioned above are correct in python3.
How can I refer to tmLanguage file that is inside .sublime-package file?
Where should I put that file? It is totally confusing why does it work on Sublime Text 2 and Sublime Text 3(when installed into dir from github) but does not work when installed via Package Control.
So, how do I set path to tmLanguage file and where should I store it. Just want to clarify, that it works fine when plugin is installed from github zip file(because I put it's content into RobotFrameworkAssistant folder under Packages directory). It does not work when plugin is installed via Package Control.
Quick summary of my manual solution of adding custom .tmLanguage files based on others' suggestions:
Put the myLang.tmLanguage file into a folder with your desired syntax
name.
Zip the folder so that it's named myLang.zip
Rename the zip archive to myLang.sublime-package
Put the myLang.sublime-package into the Sublime 3 packages folder. It will now appear in the sublime syntax highlighting menu.
Based on ST3 docs, I can't seem to find an alternative to this manual method right now, but it will work.
Package control will likely do everything you need behind the scene
Do you need the content of the tmLanguage file? If so, you shouldn't be accessing it directly. Instead, you should be using sublime.load_resource(name), where name is something like Packages/Robot Framework Assistant/robot.tmLanguage. If you are just trying to set the file syntax, you should be using view.set_syntax_file(syntax_file), where syntax_file is like name for the resource. I did not look at your plugin in detail, so please clarify what you are trying to do if both of those answers are incorrect.
As a side note, based on that error, you would probably see issues in ST2 also. You are only looking at the root packages folder, not in your package.
In ST3, jps decided to make plugins runnable from .sublime-package files, rather than needing to be extracted. These files are simply renamed .zip files. Updates do need to be made if you are accessing resources within your plugin, but the API has been extended to support it.
This isn't a great list, but it covers some of the changes in ST3 from ST2.
http://www.sublimetext.com/docs/3/porting_guide.html
The issue seems to be solved. Please refer to this fix.
Why I had problems with syntax settings(.tmLanguage) in ST3?
Because it is totally confusing and not clear from ST3 docs where that file should be located.
(Even if it says that files lookup is continued in Packages directory if file was not found in Installed Packages).
There are two 'main' folders under Sublime Text 3 directory: Installed Packages and Packages.
When the plugin is installed using Package Control it goes into Installed Packages directory packed into archive file called like Robot Framework Assistant.sublime-package (which is actually ZIP file).
The robot.tmLanguage file (syntax file) is inside Robot Framework Assistant.sublime-package.
So, in few words, my question was: how to refer to that file (what path should be provided to view.set_syntax_file method)?
Unintuitive, but I should refer to non-existent path Packages/Robot Framework Assistant/robot.tmLanguage. Actually, in my case the Packages directory contains only Users folder. The only thing, that I can guess is that folder name should be the same as package name(Robot Framework Assistant in my case).

Create a setup.exe file without any dependent files

I am a first time user of this group and so pardon me for any mistakes and unclear statements.
What I am trying to do is to create single setup.exe (not msi) using installshield. But when I build the project what I get is other files along with the .exe file for e.g. .cab, .hdr, .inx and other such files.
I am using the options under Release -> Release Wizard -> General options-> Checked the "Create a single file executable" & "Compress compiled script" options but still I get the extra files along with the setup.exe file. I want a setup.exe file to be created independent of the other local files.
So could anyone suggest me how to achieve that.
Any help will be appriciated.
Thanks.
As Michael Urman wrote, you will find the one file in adjacent folder.
The folder name is "Package".
Those files are always created for InstallScript projects. When you build a single file executable, the single file version that packages it all together is available in an adjacent folder.

AutoIt unzipping files

I've been searching all day for a solution to unzip a file with AutoIt Script. I would like to unzip a file called full.zip to a folder.
This is my last place to turn since I can't find a solution of my own. I have found many solutions made by others; AutoIt3 files containing functions, but the code has issues of which I do not understand, and I'm unable to them copy here because I'm using a screen reader and it doesn't seem to format properly. This is why I can not copy code here.
Does anyone know of a method, tutorial or resource that I can use to unzip a file with AutoIt?
Thanks for any help,
josh.
There are a lot of solutions people have coded. A few examples are the 7zip UDF, Zip.au3, zipfldr UDF. If those are not working for you it is most likely because of small changes to AutoIt, which is usually just #incudes being restructured.
I usually just keep 7za.exe (7-zip's standalone executable, 7-zip can be downloaded from here, and then after installing you can copy the 7za.exe from its program directory).
Then it becomes as simple as a call to RunWait to create the archive:
RunWait("7za.exe a MyNewArchive.zip file1.ext file2.ext ...")
And then to unzip:
RunWait('7za.exe x MyArchive.zip -o"Path\To\MyOutputFolder"')
The 7-zip FAQ also mentions that you can use this exe in your own applications (including commercial ones) provided you mention it in the documentation and provide a link. That means you are ok to use FileInstall(...) to include 7za.exe in the compiled .exe.

Can a Self Extracting Zip File read a registry entry?

I'm trying to get my website to talk to a friend's program. Think ITunes - one main program with hundreds of thousands of little things installed into it. We don't want to have to create an InstallShield install program for each of those hundreds of thousands of little things.
We have the files grouped into the folder sub-structure.
We have a .REG file for what registry entry needs to be added to see the new folder group.
But is there a way to do a self extracting zip file that reads a registry entry so we know where they installed the original program to be able to dump the new files there as well? I want them to double-click the EXE and click Finish and for everything to work.
(I've been looking into INF and CAB files through IExpress.exe, but haven't found the answer. I remember Package for the Web didn't have an option to read a registry entry, but did let you modify the suggested install path.)
Thanks so much.
Best wishes,
Andrea
But is there a way to do a self extracting zip file that reads a registry entry so we know where they installed the original program to be able to dump the new files there as well? I want them to double-click the EXE and click Finish and for everything to work
Well, yes and no. There are self-extractors that can run a program after extracting all files. DotNetZip, for example, can produce an SFX which can do this.
Just an aside: a normal SFX is just a zip file, with a "stub" executable merged with it. The stub exe can do anything it wants to do, but the most basic thing it does is extract the files in the zip. When you use DotNetZip to produce an SFX, it embeds its particular stub into the zip. That stub knows how to extract files, and also knows how to invoke a program after extracting. You can also produce your own stub that can do other more exotic things.
So you could use an SFX for your purpose. When run, it would extract, then invoke it's extra program. The program could look in the registry, then move or relocate the extracted files to the appropriate place. Then terminate.
For a different twist, the SFX might have just two files: the program-to-run (the one that reads the registry, and another embedded zip. Then when the SFX runs it generates 2 files. Then it invokes the program-to-run, which reads the registry, then unpacks the contained zip and puts the files into the desired place.
Ok, so you could do it.
Should you?
mmm, maybe. This really is an installer, so, you should decide whether you want to use a zip as an installer. Don't forget, if you use an SFX as an installer, there's no good way to uninstall.
Have you tried Inno Setup toolchain? It's a bit better than a bare Self-Extracting ZIP file, it's a setup creation utility. I'm convinced it has got something to put some entry in the Registry, look also at the plugins.
Basically, a self-extracting executable that alters the registry, it's a setup program. So why don't you go for a proper one?
Website: http://www.jrsoftware.org/isinfo.php

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