Jump to content
Ketarin forum

Easiest way to install Binaries or Executables


Omniferum
 Share

Recommended Posts

I have been for a while tinkering with a 'universal' piece of batch code that will be able to install 99% of binaries/executables that can either be unzipped or universal extracted (it's a program to extract exe/msi)

 

Here is something that works for 100+ apps from a wide variety of places. It will install the application you download to {installpath}{appname:regexreplace: \(.*\):}. The {appname:regexreplace: \(.*\):} means the name you give your application in Ketarin but will ignore anything you put in curved brackets. So if you had an app called Pony (Godilovethem) it would install to {installpath}Pony. I use this so I can put certain notes in the appname like x64 build or words like Portable/experimental.

 

 

Required defined global variables

 

{7z} - The path to your 7z program

{ue} - The path to your Universal Extract program

{temppath} - A folder that is created for all the code to be performed in, it is just a temp folder so anything will do.

{installpath} - The basic start of where you want the application to be installed to

{copyfolder} - The command run to copy the contents of what you've extracted

 

Here are how mine are defined, if you need an idea

{7z} - start /wait {root}"Programs\File Management\7-ZipPortable\App\7-Zip\7z.exe"

{ue} - start /wait {root}"Programs\File Management\Universal Extractor\UniExtract.exe"

{temppath} - {root}Ketatemp\

{installpath} - {root}Programs\

{copyfolder} - xcopy /C /E /H /I /Y

 

 

Special note

Some apps have their configuration files already defined in an .ini or .xml. There is a bit of code that accounts for it. It is this line.

 

if exist "{installpath}{category}\{appname:regexreplace: \(.*\):}"\mplayer.ini del "%dir%"mplayer.ini

 

Basically goes "Is there something already there called blah.ini? Oh ok, i'll delete it in the temp folder so it doesn't get copied over". This way you will still keep all your old settings, which is kinda the point. Just replace mplayer.ini with whatever filename you know keeps the config data. Usually config.ini or config.xml, for some apps it can also be a .db.

 

 

For binaries

{7z} x "{file}" -o"{temppath}{appname:regexreplace: \(.*\):}" -y
for /f "tokens=2 delims=[]" %a in ('dir /b /s "{temppath}{appname:regexreplace: \(.*\):}\*.exe" ^| find /v /n "" ^| findstr /c:[1]') do set dir=%~dpa*
{copyfolder} "%dir%" "{installpath}{category}\{appname:regexreplace: \(.*\):}\"
rd /s /q "{temppath}{appname:regexreplace: \(.*\):}"

 

For executables

{ue} "{file}" "{temppath}{appname:regexreplace: \(.*\):}"
for /f "tokens=2 delims=[]" %a in ('dir /b /s "{temppath}{appname:regexreplace: \(.*\):}\*.exe" ^| find /v /n "" ^| findstr /c:[1]') do set dir=%~dpa*
{copyfolder} "%dir%" "{installpath}{category}\{appname:regexreplace: \(.*\):}\"
rd /s /q "{temppath}{appname:regexreplace: \(.*\):}"

 

Now the only issue at the moment with the above code is that it will leave you with an empty temp folder. The reason for this is you can't delete it if you have other apps that are using it at he same time, otherwise it will just screw everything up.

 

If you put the following

 

rd /s /q "{temppath}"

 

into the "After updating all application" (It is a drop down menu) in the Commands tab in Settings it will clean it up when Ketarin is basically finished with everything. Floele has said he will put in an "Execute command after installing" which we can put it in there then, because manually installing/running the code will still leave you with an empty temp folder.

 

 

EXTRA

 

There are two places you can place install instructions. In either the commands tab or the Setup tab of the applications settings. In the setup tab if you click "Add Instruction" and select "Custom Command" you can paste the above code into there and it will work.

 

Also if you place the following.

 

/*This is a comment line, the line below is the C# script. It will run the instructions found in the Setup Tab*/

app.Install(null);

 

Into the 'execute the following command after downloading' part of the commands tab and from the drop down menu labelled Command select C# script it will run whatever you put into the Setup Instructions everytime it downloads an update.

Edited by Omniferum
Link to comment
Share on other sites

Yeah thats the conflict - You can make a very complex and thorough command that will install most things but is naturally slower.Or you can make a very simple command that is more likely to break if something big changes.

 

Generally i have opted to unpack files to %temp% and install from there.That way i won´t have to deal with garbage collection post-install.

Link to comment
Share on other sites

If my batch was something like 50 lines i'd agree with you, but the speed of mine is fast enough to not notice the difference. Maybe if you ran it on a very very slow machine.

 

My batch does take care of the temp folder, just doesn't delete the empty folder afterwards. You would still have to empty your %temp% folder, this is for those that tend to not do that. Again, for those new to any of this.

Edited by Omniferum
Link to comment
Share on other sites

  • 1 month later...

{7z} - start /wait {root}"Programs\File Management\7-ZipPortable\App\7-Zip\7z.exe"
{ue} - start /wait {root}"Programs\File Management\Universal Extractor\UniExtract.exe"

 

You should probably always use

start "" /wait [...]

This solve problemes with path having spaces and/or quotes.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.