Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: Clyde on October 31, 2006

Title: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
Does anyone know how to create a batch file using UPX, and then being able to click on an EXE so that you can send the program to the UPX Batch File so it can be compressed; without the need for using the command prompt each time?

Cheers and many thanks,
Clyde.
Title: Re: Creating a batch file for UPX.
Post by: Shockwave on October 31, 2006
Well, you can make a batch file with notepad to do pretty much anything..
Put your commands in the batch file and save it with a .bat extension.
That should work fine for you.
Title: Re: Creating a batch file for UPX.
Post by: ninogenio on October 31, 2006
youll need your enviroment details set in windows if you have windows xp

then got to start and right click my computer and propertes now go to enviroment variables scroll down your system variables to path and click edit and add the path of the upx folder where the exe lies to the varialbles already there make sure you have a semicolon ; before and after the path or it wont work.

now what thats done is let you acsses upx from anywhere under the cmd prompt.

to make the bat file create a new txt file and add your switches to the new file it will probably be something like this

upx -c my.exe /this is just submizing where i put upx just put the actuall name of the upx.exe and im not sure what or if the -c will be needed have a read through the upx read me/

then save it as make.bat

put the bat file next to my.exe click it and it should* do the work for you.

if any of thats unclear or if it simply doesnt work just give us a post and ill download upx and get it going for you bud ;)
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
There was a way of doing it as I had it on my machine before I had to reformat and re-install; but I can't find where I got the information.

Im stuck as I dont know what the commands are for dealing with any file via UPX and the "Send To" list which you get from doing a right click on the mouse. If you could give us a hand Nino that would be superb.

Cheers and many thanks,
Clyde.
Title: Re: Creating a batch file for UPX.
Post by: ninogenio on October 31, 2006
i just downloaded it there and changed my eviroment variables to as i said above then made a .bat file by making a new txt file and adding this

upx my.exe

and saved it to make.bat and it worked but im not quite sure thats what your wanting as it would mean making a new bat file for each exe?
Title: Re: Creating a batch file for UPX.
Post by: cirux on October 31, 2006
What I have is just a text file called upx.bat with

Code: [Select]
c:\upx\upx -9 %1

pause

And can drag exe's on to it and it will overwrite the file with the compressed version.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
Thanks Nino & Cirux.

How can I have that in the Send To List?
Where you right Click, for example the same list that Winzip is on, there's a Send To.
Title: Re: Creating a batch file for UPX.
Post by: cirux on October 31, 2006
Yeah you can just copy that bat file into

Code: [Select]
c:\documents and settings\[username or all users]\send to

You need to have show hidden files option on to see the send to menu (if its not on you can enable show hidden files from any explorer window ->tools->folder options.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
Cheers dude.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
Will that work for any version of UPX?
As it doesnt appear to be compressing some of my exes.
Title: Re: Creating a batch file for UPX.
Post by: cirux on October 31, 2006
Will that work for any version of UPX?
As it doesnt appear to be compressing some of my exes.

Is the upx file saying there was no compression or windows? I noticed windows doesn't always update the file size info straight away, I have to right click properties or refresh the screen a few times.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
There's nothing being displayed at all once I've sent the file to the batch file. All I get is the press a key from the pause command.
Im using UPX202w.

Cheers Clyde.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
This is what I get mate:

Code: [Select]
C:\Documents and Settings\Clyde>C:\Documents and Settings\Clyde\My
 Documents\PC Arena\Tools\UPX\upx202w\upx -9 "C:\Documents and Settings\Cly
de\My Documents\Free Basic Arena\My Freebasic Programs\Brimstone\Brimstone.exe
"
'C:\Documents' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Clyde>pause
Press any key to continue . . .
Title: Re: Creating a batch file for UPX.
Post by: cirux on October 31, 2006
Looks like UPX doesn't like being in a directory with spaces in it? Maybe try put it in c:\upx or similar and see if that works?
Title: Re: Creating a batch file for UPX.
Post by: Clyde on October 31, 2006
Ok will do and thanks. I had this kind of problem before with FBIDE and resources.
Cheers Cirux.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on November 01, 2006
That worked nice one mate, funny that I had upx in the same location when I had an older version and it worked from being in a directory with spaces. Bizzarre.

Thanks Cirux.

All the best,
Clyde.
Title: Re: Creating a batch file for UPX.
Post by: cirux on November 01, 2006
No problem, glad I could help. Thinking about it more, I wonder if its because of it being used in a batch file that causes the problem and not UPX.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on November 01, 2006
How could we test this out?

Thanks,
Clyde.
Title: Re: Creating a batch file for UPX.
Post by: cirux on November 01, 2006
I will try a few things out with UPX (I am using the same version as you) and batch files to check, will let you know what I find out.
Title: Re: Creating a batch file for UPX.
Post by: Jim on November 01, 2006
You've just missed out some quotes.  You need quotes round each part that has spaces in.
ie.
This is (somelthing like) what you have in your batch file...
Code: [Select]
C:\Documents and Settings\Clyde\My Documents\PC Arena\Tools\UPX\upx202w\upx -9
It should be
Code: [Select]
"C:\Documents and Settings\Clyde\My Documents\PC Arena\Tools\UPX\upx202w\upx" -9

Jim
Title: Re: Creating a batch file for UPX.
Post by: Clyde on November 01, 2006
Cheers Jim, nice one.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on August 22, 2007
Has anybody sussed this out with Windows Vista?
Title: Re: Creating a batch file for UPX.
Post by: Jim on August 23, 2007
It's the same under Vista, except Documents and Settings has moved (yes, AGAIN!).
It's now

c:\users\jim\documents

which would make your path
Code: [Select]
C:\Users\Clyde\Documents\PC Arena\Tools\UPX\upx202w\upx -9

Jim
Title: Re: Creating a batch file for UPX.
Post by: Clyde on August 23, 2007
Cheers Jim :)
Title: Re: Creating a batch file for UPX.
Post by: Clyde on August 26, 2007
I cant seem to find where to put the batch file so I can use the Send To / Left click like with winzip etc; in vista. Is it a hidden folder?

Cheers and many thanks,
Clyde.
Title: Re: Creating a batch file for UPX.
Post by: Clyde on August 26, 2007
Found it:

C:\Users\[UserID]\AppData\Roaming\Microsoft\Windows\SendTo\