Skip to content

Commit efa7d9e

Browse files
committed
option to enable/disable UPX compression + update 7za
1 parent 20677a1 commit efa7d9e

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

bin/7za.exe

8.5 KB
Binary file not shown.

hta/process.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,45 @@ function sendToBatch() {
88
var completion = form.elements['completion'].checked;
99
var distname = form.elements['distname'].value;
1010
var icon = form.elements['icon'].value || false;
11+
var upx = form.elements['upx'].checked;
1112
if (icon && !hasExtension(icon, ['ico'], true)) return false;
1213
if (isRequired(srcfile) && hasExtension(srcfile, ['bat', 'hta'], true) && isRequired(distname) && isWinFilename(distname)) {
1314
var src = splitPath(srcfile);
14-
var output = src.folder +'~'+ src.file +'~'+ include +'~'+ hidcon +'~'+ completion +'~'+ distname +'~'+ icon;
15+
var output = src.folder +'~'+ src.file +'~'+ include +'~'+ hidcon +'~'+ completion +'~'+ distname +'~'+ icon +'~'+ upx;
1516
if (!checkOverwrite(distname, src.folder)) return false;
1617
fso.GetStandardStream(1).Write(output);
1718
window.close();
1819
}
1920
}
2021

22+
function changeDistname() {
23+
var form = document.forms[0];
24+
var srcfile = form.elements['srcfile'].value;
25+
var distname = form.elements['distname'];
26+
distname.value = srcfile.split('\\').pop().replace(/\.[^/.]+$/, '');
27+
changeHideConsole();
28+
}
29+
30+
function changeHideConsole(){
31+
var form = document.forms[0];
32+
var hidcon = form.elements['hidcon'];
33+
var srcfile = form.elements['srcfile'].value;
34+
if (hasExtension(srcfile, ['bat'], false)) {
35+
hidcon.disabled = false;
36+
removeClass(hidcon.parentNode, 'text-muted');
37+
} else {
38+
hidcon.disabled = true;
39+
hidcon.checked = false;
40+
hidcon.parentNode.className += ' text-muted';
41+
changeCompletion();
42+
}
43+
}
44+
2145
function changeCompletion() {
2246
var form = document.forms[0];
2347
var completion = form.elements['completion'];
2448
var hidcon = form.elements['hidcon'];
25-
var srcfile = form.elements['srcfile'].value;
26-
if (hidcon.checked && hasExtension(srcfile, ['bat'], false)) {
49+
if (hidcon.checked) {
2750
completion.disabled = false;
2851
removeClass(completion.parentNode, 'text-muted');
2952
} else {
@@ -33,13 +56,6 @@ function changeCompletion() {
3356
}
3457
}
3558

36-
function changeDistname() {
37-
var form = document.forms[0];
38-
var srcfile = form.elements['srcfile'].value;
39-
var distname = form.elements['distname'];
40-
distname.value = srcfile.split('\\').pop().replace(/\.[^/.]+$/, '');
41-
}
42-
4359
function splitPath(input) {
4460
input = input.split('\\');
4561
var file = input.pop();
@@ -56,10 +72,10 @@ function isRequired(input) {
5672
}
5773

5874
function hasExtension(input, extensions, feedback) {
59-
var hasOne = extensions.filter(function(value){
60-
return input.indexOf(value, this.length - value.length) > -1
75+
var hasOne = extensions.some(function(ext){
76+
return input.indexOf(ext, input.length - ext.length) > -1
6177
})
62-
if (!hasOne[0]){
78+
if (!hasOne){
6379
if (feedback) errorFeedback('.is-ext', 'Not a ' + extensions + ' file');
6480
return false;
6581
}

hta/thebatchman.hta

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
<head>
44
<meta http-equiv="x-ua-compatible" content="ie=9">
55
<script language="javascript">
6-
var appSize = { width: 350, height: 490 };
6+
(function () {
7+
var appSize = { width: 350, height: 520 };
78
window.resizeTo(appSize.width, appSize.height);
89
window.moveTo((screen.width - appSize.width) / 2, (screen.availHeight - appSize.height) / 2);
10+
})()
911
</script>
1012
<title>The Batchman</title>
1113
<hta:application id="app" scroll="auto" sysmenu="yes" showInTaskbar="yes" caption="yes" border="thin" icon="../thebatchman_icon.ico" maximizebutton="no" minimizebutton="no" navigable="yes" singleInstance="yes">
@@ -53,11 +55,20 @@
5355
<strong class="form-control-feedback hide">&#10006;</strong>
5456
</div>
5557

56-
<div class="form-group mb15 mt25">
58+
<div class="form-group mt20 mb15">
5759
<div class="checkbox">
5860
<label>
59-
<input type="checkbox" name="hidcon" onchange="changeCompletion()">
60-
Hide the console when running your exe ?
61+
<input type="checkbox" name="upx">
62+
Compress the exe with UPX ?
63+
</label>
64+
</div>
65+
</div>
66+
67+
<div class="form-group mb15">
68+
<div class="checkbox">
69+
<label class="text-muted">
70+
<input type="checkbox" name="hidcon" onchange="changeCompletion()" disabled>
71+
Hide the console when running the exe ?
6172
</label>
6273
</div>
6374
<div class="checkbox">

thebatchman.bat

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
@echo off
22
setlocal
33

4-
for /f "tokens=1-7 delims=~" %%i in ('mshta.exe "%~dp0\hta\thebatchman.hta"') do (
4+
for /f "tokens=1-8 delims=~" %%i in ('mshta.exe "%~dp0\hta\thebatchman.hta"') do (
55
set "srcdir=%%i"
66
set "srcfile=%%j"
77
set "include=%%k"
88
set "hideconsole=%%l"
99
set "completion=%%m"
1010
set "name=%%n"
1111
set "icofile=%%o"
12+
set "upx=%%p"
1213
)
1314
if "%srcfile%"=="" goto :eof
1415
start "" mshta.exe "%~dp0\hta\wait.hta"
@@ -58,7 +59,9 @@ start /b /wait "Resourcer" "%~dp0\bin\resourcer.exe" -op:add -src:"%temp%\%name%
5859
copy /b /y "%temp%\%name%.icx" + "%temp%\%name%.tmp" "%distexe%"
5960

6061
:: Compress executable with UPX
61-
start /b /wait "Compressing" "bin\upx.exe" -1 -q "%distexe%"
62+
if "%upx%" == "true" (
63+
start /b /wait "Compressing" "bin\upx.exe" -1 -q "%distexe%"
64+
)
6265

6366
:: Cleaning
6467
if exist "%sfxconfig%" del /q /f "%sfxconfig%"

0 commit comments

Comments
 (0)