Skip to content

Commit

Permalink
ExtractTarGZ.bat works again
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-lebedkov committed Jul 1, 2016
1 parent 3740680 commit d746c0b
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 6 deletions.
2 changes: 1 addition & 1 deletion AddTargetDirProperty.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ rem This script adds the property named TARGETDIR to an .msi file
rem
rem Script parameters: none
for /f "delims=" %%x in ('dir /b *.msi') do set setup=%%x
"%SYSTEMROOT%\System32\cscript.exe" "%~dp0\private\AddTargetDirProperty.vbs" //B //NoLogo //U //E:VBScript "%setup%"
"%SYSTEMROOT%\System32\cscript.exe" "%~dp0\private\AddTargetDirProperty.vbs" //NoLogo //U //E:VBScript "%setup%"

3 changes: 1 addition & 2 deletions ExtractTarGZ.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ rem
rem Script parameters:
rem %1 - name of the .tar.gz file. The value should end with ".tar.gz"
rem
"%~dp0\private\tar.exe" -xvzf "%~1" > .Npackd\Output.txt 2>&1 && type .Npackd\Output.txt
if %errorlevel% neq 0 exit /b %errorlevel%
"%SYSTEMROOT%\System32\cscript.exe" "%~dp0\private\ExtractTarGZ.js" //NoLogo //U //E:JScript "%~dp0" "%~1"

15 changes: 15 additions & 0 deletions InstallMSU.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
rem This script is available since version 1.17
rem This script installs an .msu file as Npackd package
rem There must be only one .msu file in the current directory.
rem
for /f "delims=" %%x in ('dir /b *.msu') do set setup=%%x
mkdir .Npackd
move "%setup%" .Npackd
set err=%errorlevel%
if %err% neq 0 exit %err%

wusa ".Npackd\%setup%" /quiet /norestart /log:.Npackd\InstallMSU.log
set err=%errorlevel%
wevtutil.exe qe .Npackd\InstallMSU.log /lf:true /f:Text /uni:true

if %err% neq 0 exit %err%
21 changes: 19 additions & 2 deletions Lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,14 @@ L.unregisterOpenWith = function(key, extensions) {

/**
* This function is available since 1.13.
* Since 1.18 .tar.gz is also supported.
*
* Unpacks the specified file or directory and deletes
* the file or directory. Unpacking a directory means moving all the contents
* one level up.
*
* @param file a .7z, .tar, .gz file or a directory. All other file extensions
* will result in an error.
* @param file a .7z, .tar, .gz or .tar.gz file or a directory.
* All other file extensions will result in an error.
* @param target target directory
*/
L.unpackAndDelete = function(file, target) {
Expand All @@ -311,6 +312,22 @@ L.unpackAndDelete = function(file, target) {
// ignore. This can happen if there are not sub-directories.
}
f.Delete(true);
} else if (file.match(/\.tar\.gz$/i)) {
var r = L.exec("\"" + this.installerHelper +
"\\private\\7za.exe\" x " +
"\"" + file + "\"");
if (r[0] !== 0)
throw new Error("Failed to unpack the .gz file " + file);
fs.DeleteFile(file);

file = file.substring(0, file.length - 3);
var r = L.exec("\"" + this.installerHelper +
"\\private\\7za.exe\" x " +
"\"" + file + "\" " +
"-o\"" + target + "\"");
if (r[0] !== 0)
throw new Error("Failed to unpack the .tar file " + file);
fs.DeleteFile(file);
} else {
var r = L.exec("\"" + this.installerHelper +
"\\private\\7za.exe\" x " +
Expand Down
2 changes: 1 addition & 1 deletion SendKeysToWindow.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ rem %1 - title of the window. If no exact match is found, any window whose
rem title with the specified title is activated
rem %2 - the keys as described here: https://msdn.microsoft.com/en-us/library/8c6yea83%28v=vs.84%29.aspx
rem
"%SYSTEMROOT%\System32\cscript.exe" "%~dp0\private\SendKeysToWindow.js" //B //NoLogo //U //E:JScript "%~dp0" "%~1" "%~2"
"%SYSTEMROOT%\System32\cscript.exe" "%~dp0\private\SendKeysToWindow.js" //NoLogo //U //E:JScript "%~dp0" "%~1" "%~2"

13 changes: 13 additions & 0 deletions UninstallMSU.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rem This script is available since version 1.17
rem This script uninstalls an .msu file as Npackd package previosly installed
rem by InstallMSI.bat.

move .Npackd\*.msu .
for /f "delims=" %%x in ('dir /b *.msu') do set setup=%%x

wusa /uninstall "%setup%" /quiet /norestart /log:.Npackd\UninstallMSU.log
set err=%errorlevel%
wevtutil.exe qe .Npackd\UninstallMSU.log /lf:true /f:Text /uni:true

if %err% neq 0 exit %err%

13 changes: 13 additions & 0 deletions private/ExtractTarGZ.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
try {
var fs = new ActiveXObject("Scripting.FileSystemObject");
var sh = WScript.CreateObject("WScript.Shell");
var lib = eval(fs.OpenTextFile(
WScript.Arguments(0) + "\\Lib.js", 1).ReadAll());
lib.installerHelper = WScript.Arguments(0);

lib.unpackAndDelete(WScript.Arguments(1), ".");
} catch (e) {
WScript.Echo(e.name + ": " + e.message);
WScript.Echo(e.number + ": " + e.description);
WScript.Quit(1);
}

0 comments on commit d746c0b

Please sign in to comment.