How to extract, modify and rebuild a Cabinet File? - windows

I can successfully extract Cabinet files (.cab) using the Windows tool Expand.exe.
Expand.exe foo.cab -F:*
I now want to modify some extracted files and rebuild a Cabinet file from the directory structure.
I found MakeCab.exe and CabArc.exe and tried MakeCab.exe but it doesn´t work.
(There are several files with the same name in different subdirectories and MakeCab.exe doesn´t like that. But the directory structure and the files come from a Cabinet file, so it has to work somehow.)
For extraction I also tried the Linux tool cabextract, which gave me another output with less files/directories extracted.
So I assume there are files in the Cabinet file which also are archived and Expand.exe extracts them too.
So how can i extract, modify and rebuild a Cabinet file?
(The Cabinet files come from WSUS / Windows Update.)

It's not supported to modify a Windows Update (WU) CAB. The CAB files you download from WU are digitally signed by Microsoft and Windows will refuse to install them if the signature is invalidated. Additionally, without special configuration the WSUS server will also realize the CAB files have been modified and re-download fresh copies from the upstream server or MU.

To my surprise, there seems a software from ACD: ACDzip (now discontinued program) that CAN MODIFY the .CAB files.

You can make cab file by using makecab.exe in cmd, if you have multiple files,then you can use makecab file directives to add files to .cab file.
makecab /f name.ddf
The Directive file (.ddf) is
.Set CabinetNameTemplate=cabName.cab
.Set SourceDir=PathWhereYouWantToMakeCab
.Set Cabinet=on
.Set Compress=on
"file1name.txt"
"file2name.txt"

See my answer to this question:
C#/.NET: Creating a CAB and adding files to it without an external library
However, as BenH points out in his answer, the resulting cab file wouldn't work as a substitute WU cab file. But, if all you want is access to the FILES AND FOLDERS inside the WU cab file, e.g. DLLs or driver files, etc. then the approach I described should get you there.
For the approach in my linked answer, note that the CabMaker app is a GUI wrapper around the the MakeCab program and handles the DDF file creation and the MakeCab command line creation for you. Below is what the CabMaker GUI looks like.

I suggest MakeCab.exe is best tool to create the cabinet files.
You should rename your source files.

Related

Does NSIS support external files?

I basicaly want to have an external very large (bigger than 2gb) file next to my setup executable. To realize this, in the script I have tried the following:
File "$EXEDIR/verybigfile"
However, I got the following error:
File: "$EXEDIR/verybigfile" -> no files found.
Is it possible to do this in NSIS or do I require a plugin to realize this?
Thanks.
The File instruction cannot use variables like $EXEDIR, it needs the local path on your machine but you will hit the 2 GiB limit because these files are stored inside the installer.
If you are shipping a DVD or something like that you can use CopyFiles /SILENT "$EXEDIR\files\*.*" "$InstDir" to copy files from a DVD to the users system. This instruction does not support any kind of decompression, it is just a plain copy operation.
You need to use a plug-in to extract from .ZIP/.7z files.

Where is the location on the extracted .msi file?

I have a setup exe, and I want its .msi file for administrative installation (see https://superuser.com/questions/307678/how-to-extract-files-from-msi-package)
But, although I see at the beginning the extraction of .msi, I can't find it.
Where is the location of this file?
Usually MSI file(s) might be extracted in different temp locations depends from who was launched (User\System\etc) and how configured setup.exe. Sometimes you can extract it with help of different command-line switches for setup.exe.
The simple way to check - launch it under user account, go to %temp% folder, most likely there should be created folder with {GUID_view_name}. Inside this folder you will find MSI file.
User's %temp% folder has different location in different Windows versions:
Windows XP\2000\2003:
"C:\Documents and settings\{user name}\Local settings\Temp" or "%userprofile%\local settings\temp"
Windows Vista\7\8\2008\2012
"C:\Users\{user name}\AppData\Local\Temp" or "%userprofile%\appdata\local\temp"
P.S. Also you can check this SO question-answer.
Snapshot a clean VM and use a program such as Install Watcher or InCntrl to record the current state of the file system. Run the setup.exe until you are on the first dialog of the MSI and take another recording. Diff and look for where the MSI and related support files appear.
I found a much better solution, Igor, gave me the idea.
I used ProcessMonitor and filtered with Process is "msiexec.exe" and Path ends with ".msi".
I found the msi in:
C:\ProgramData\Downloaded Installations\{41A70E83-DA5D-4CA6-9779-73C9330E3D13}\IQProtector64.msi

Windows 7: Running application using App Paths vs Batch File

I have an (PowerBuilder) application (let's call it MyApp.exe) in a folder with a sub-directory that has all the required dlls. I am able to run this application, by adding the application path and associated path variable to Windows App Paths registry key.
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\App Paths\MyApp.EXE]
"Path"="C:\\Prog32\\MyAPP;C:\\Prog32\\MyAPP\\DLL\\;"
#="C:\\Prog32\\MyApp\\MyApp.EXE"
The above runs file. I didn't even have to register DLLs.
If possible, I would like to run it using a batch file though, as users may install multiple versions of the same application in separate folders. When I tried to do the same thing in a batch file, it cannot find the DLLs.
#SETLOCAL
SET CURDIR=%~dp0
CD %CURDIR%
PUSHD %CURDIR%
SET PATH=%CURDIR%;%CURDIR%\dll;%PATH%
start "" %CURDIR%\myApp.exe
POPD
ENDLOCAL
I created this batch in the same directory as the executable, MyApp.exe. I was expecting it would find the DLLs, same way App Paths PATH setting did. The Batch file errors out not being able to find the DLLs. Do we need to register DLLs in this case? Why is it treated differently?
Notes:
If I copied all the required DLLs to the same directory as the executable (without a DLL sub-directory), it runs fine without needing to worry about PATH or registering dlls.
We used to use installShield to install before, but admins have automated scripts to copy files, they shied away from InstallShield programs after the first install. I am trying to refine the process, so what they copy will be simplified.
Thanks in advance for all your valuable comments and suggestions.-Sam
Why is it treated differently?
Because Windows is a mess when searching for libraries. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspx#search_order_for_desktop_applications
There are many elements to how the search order is determined, but in general it is like this
Check for the library...
already loaded in memory
on the KnownDLL list
in the application's directory
in the System directory
in the 16-bit System directory
in the Windows directory
in the current working directory
in the directories listed in the PATH environment variable
Overall I would agree with what MSDN states on their DLL Redirection page
It is good practice to install application DLLs in the same directory that contains the application
However, if using sub-folders is how you want to organize your application,
you might take a look into using Application Manifests. Something else to try would be to set the library directory as the working directory
#ECHO off
SETLOCAL
SET "CURDIR=%~dp0"
PUSHD "%CURDIR%\dll"
start "" /D "%CURDIR%\dll" "%CURDIR%\myApp.exe"
POPD
ENDLOCAL

Error 1334 .File cannot be found in the Data1.cab

I am working on a Win 7-64 bit machine. I have a software installation package which contains the .msi file, a CAB file and some MST files. I wanted to modify the cabinet file. So I extracted the cab file using CABARC utility.
But before making any changes to the extracted files, just for testing the utility I removed the original cab file from the current directory. And created a new cab file from the files extracted from the original cab file, again using CABARC utility.
But now if I run the .msi file, it shows the error:
ERROR:1334. The file "XYZ" cannot be installed because the file cannot be found in the cabinet file Data1.cab. This could indicate a network error, an error reading from the CD-ROM, or a problem with this package.
But the file is present in the cabinet file I can see that. The same installer is working fine with the original cab file.
I have tried different compression types (MSZIP, LZX:<15...21>) as well, but none of them work. I have not removed/added any file in the cabinet file. Am I doing anything wrong or if there is any other information that a cabinet file stores ?
Thanks.
This error when the setup path exceed the path limit for OS. Try changing output path for installer path to some shorter path.

How to export ftp list from phpdesigner 8?

I've got ftp connections list in phpDesigner.
How to export or to save it?
you can find the ftp xml file in:
C:\Users\your user dir\AppData\Roaming\phpDesigner
phpdesigner_ftp.xml
For Windows XP users (and I assume they still exist in numbers!)... the Path is:
C:\Documents and Settings\[Windows-User]\Application Data\phpDesigner
For example, I've Windows User account with the name "Ruturaaj". So, my path looks like:
C:\Documents and Settings\Ruturaaj\Application Data\phpDesigner
It's quite handy to know this folder because it contains some other useful XML files as well. For example, look for "autocomplete.xml". This is the file that contains all Auto-Complete code snippets you've added to phpDesigner over a period of time. Now that you know this folder path, I'd suggest to backup this folder and simply overwrite the files with new installation to setup same environment over and over again.

Resources