 Okay, I hope this tutorial goes well. This is something I've done a number of times, but it's not something I do too often But hopefully I'll be able to explain it well and clearly and show you some hurdles You might hit in doing this If you've been watching this series and hopefully you have if you haven't there should be an annotation on the screen That will bring you to the playlist you can watch the playlist And I'm showing basic ways of repackaging the same program to run on multiple operating systems Whether it be a mobile device like Android iPhone Windows mobile or on desktop such as Linux Mac or Windows And so far most of what I've shown has been cross-platform Either using Python or C++ And once you do that, it's a matter of recompiling or sharing the proper libraries and your code will run on all those operating systems I showed you one way recently in the last Video or video before that to turn your HTML file into an HTA file which in Windows will make it seem more like an application. So here's the program we made in the first part of this series But you can see it's running. It's running in a browser, but not really. I mean it doesn't have your toolbar It's basically I'm pretty sure using Internet Explorer as a back-end But it gives you more options as I showed in the previous video working with this on how the border looks whether you have An icon so it gives it more of a local application feel even if it's a web app So but that is having these multiple files and having it be an HTA file with this default icon But today we're going to package all that into a exe file Which is basically a self-extracting exe file that will run our program This is the benefit of one having everything in one package instead of multiple files and two it People are more likely to realize that the exe is an executable rather than HTA So we're gonna do this there's multiple ways there's lots of ways out there to make self-extracting zip files Some proprietary some open source There's benefits and drawbacks to using this technique, but we're gonna use seven zip Why because one reason seven zip itself is cross-platform and also is at least somewhat open source under a GNU LGPL plus some unraw restrictions. I haven't gone into Looking into exactly what the licenses are, but at least it's somewhat open source if not completely Well, I guess it's completely open source, but is it truly free software? I'm not sure I haven't read the entire license, but anyway on your Windows machine. You'll download you'll go to 7-zip.org and you will download this exe for their window for Windows machines and Install it and then that will give you the their manager for creating seven zip files Also while you're here Go to the download link and you'll want to download this 7-z file that has the 7-z libraries SFX for installers because we're gonna be creating an installer and really this is used for creating installers We're actually gonna just make it a standalone application. So there's gonna be some tweaks we need to make Because by default this technique is supposed to Extract everything to a temporary file and then run an installer that moves everything where it's supposed to go Which is kind of what we're gonna do, but we're gonna skip the actual visual installer part and just open our application So once you've downloaded and unzipped that file Within that file there is a file called 7z s dot s FX I very extracted that file into the same folder as our project Also in here. I have created a config dot txt. Let's open that up and I'll try to remember to put a link in the description to Exactly how this is right now but basically you write this out like this in here and if you Google this there's actually a whole lot of options you Can put in here for different things when it comes to your installer But our this this part of our application since our application is so small You're not even going to see this up on the screen So even though we're saying a title you're not going to see that title and even though there should be a progress bar You're actually not going to see the progress bar because it's going to go so fast But if you were there's a lot of options out there that we're not going to get into now this Installer needs to run some sort of executable file Which an hta is not considered an executable file really? Two that I know of are either an exe file Which if we already had we wouldn't have to worry about this or a batch script So we have a batch file here. I'm saying we're going to create a file called batch one which we're going to create right now So what I'm going to do is I'm going to say file new and What I'm going to do for right now. I'm just going to say echo Hello world really the script will be the one that actually moves our project to a separate temporary file and then runs it And then I'm going to pause that we will now save this as It is we have to change this to all files and say one dot BAT For a batch file save it come in here and double-click that you can see it runs it prints out Hello world and then pauses doesn't really matter Where we have echo on or off in this particular case because once again This particular program is going to be so small that you'll see this flash on the screen real quick and go away before our actual application opens up So now that we have that just as an example, let's Select all but then we'll deselect our SFX file and our TXT file I am going to then right-click the left the files that are left go down to seven zip since I installed the Seven zip manager this now appears in my drop-down menu here, and I'll add it to list dot 7z the name list it doesn't really matter what's called it just by default pick that because that's what our folder We're currently in is called so basically we have this seven zip file Which anyone can extract and get these files out of but we're going to do is we're going to take this file This file in this file and combine them all in an executable file Basically, this is like the header of the executable This is telling it how to run and then this is what's going to extract So we're going to do this by opening up our shell here or our terminal cmd Navigating to the folder that we're currently our project is in and then we're going to run this command copy space forward slash be the name of our SFX file Which since it's in the current directory is just name of that if it's in a different directory You can give the full path to it plus config dot txt plus List dot 7z because that's the name of our 7z file and then we want our what our executability be called So in this case, I'm going to call it list dot exe Basically since most my viewers are Linux users or probably maybe Mac users or other Unix based or like operating systems This is like concatenating using cat to put all these files into one file We'll hit enter there. It has now created an exe file. It gives it this installer icon It's getting that from this SFX file and now if we were to double-click this. Oh It opens just behind me. Okay. It opens up this shell this terminal screen that ran our batch one file That's great. Now. What we want to do is actually have it run our Our hta file So what we're going to do is we're going to go into our batch file here not that one this one And instead of echo. Hello world. We're going to change that to say start Index dot hta, which is our hta file right here and start basically is like Forking it's it's starting a new process, which would be this index dot hta And then pause will pause that script which we're going to get rid of in a minute But I just want to show you this so again we'll Delete both our executable and our seven zip file here Select all of these except for Our config and our SFX file and we will right-click and Create a new list 7z file and We'll run that copy command again Create a new exe now when we double-click and run it you can see we get our Our application here and it works great. It's running out of a temporary file now our folder now And we have what we still have our terminal screen open here because I put that pause command So you might think oh, we'll just get rid of that pause command and that will close in the background since we're starting a new Process here. Well, let's give that a try and obviously you can tell by the tone of my voice That's not going to work So we'll delete ours zip file and our exe file once again select everything but those two put them into a list dot 7z file and Recreate our exe file now when you run it. Oh, we get our hta window But nothing in it and the reason is before this has a chance to load Since our batch script has done has finished running it has now deleted the temporary folder So those files no longer exist So what we actually need to do in this case is Before the batch scripts ends running we're gonna have the batch script copy everything add the temporary folder Into a new temporary folder at least this is my solution to this So what I'm going to do here is I'm going to say x copy not just copy because we do have a folder in here And the regular copy command and windows cannot copy recursively but x copy can and I may have to look at my notes here real quick. Yep. That's what I thought okay x copy Astric for everything And then we're going to copy it. Well first let's make a folder to copy it too. So I'm going to make directory dot dot Backslash because we're in Windows and we're gonna say my app So we're creating a directory here, and then we're gonna say copy everything from this directory into my app directory forward slash e I Think that's saying recursively. I believe and then we're going to start our Dot-dot slash my app and Then our index so basically we are creating a new directory Above the directory we're in and then we're going to copy everything from the current directory Which is a temporary directory into that directory then we'll start it and then we'll exit out of the batch script So we'll save that hopefully I did everything right in there If not, I'll have to check my notes real quick because I don't work with batch files very much used to 10 years ago Let's see Once again, we will create our zip file here And really you can see this is real easy as far as creating our executable file I'm just showing you some hurdles you might hit and the solutions I came up with to get them because once again this is designed to run an installer and we're not really running the installer We're just running our application double-click that and This is the problem we're going to come into and this I let let me let me redo that Yes, and that Remove both these files instead of my app because as you saw that folder already exists. I'll say my app P well, I'll do with three P's there Save that again oops Put all those in there We're on our copy command again Now when we run a look, we don't have the terminal window and we have our application which is working great Let's run it again We get an error the reason we're getting error or at least a warning is that the file the folder we created or he exists So it's asking are you sure you want to override that and Although there are options when you're copying to just say yes another solution which might be a good solution is This option here So what I'm doing here is I'm creating a random number and I'm setting the variable X to that and Then instead of just calling the folder my app I'm calling it my app and then that random number so every time this script runs It will create a new folder with a random number at the end So you're not going to accidentally overwrite information that's already there Because the chances of you calling up the same random number More than once in a session is unlikely So we're just saying instead of my app We're saying my app and in Windows percent X percent is how you call the variable and we do that for all three of these lines I will save that batch file over the old one Let's remove these two Create our new seven zip file run Our copy command and now we have this executable We can give to anybody because all these other files are already in it. They can click it They get that little terminals or terminal screen for a second, but doesn't really matter They're not really going to see it there and then and then your application opens up and runs and So that is one way of packaging a self-extracting executable file in in Windows now Like I said, there are a lot of other ways that some people might find more simple. There are gooey interfaces to create stuff like this I know When zip does some of those are proprietary programs. I personally don't like using proprietary programs This process is pretty simple. It's basically creating a config file and then running this copy command Pluses to using this technique is one you can do the same exact thing in Linux so if you have your Your your project your HTML file you can rename your HTML file to dot HTA and Then you can create a seven zip file in in Linux and then instead of copy you can just use Cat and what you can do is you can cat all these files like so Into an exe file so you're piping it into or redirecting it into an exe file So that's a plus of using this technique as long as you have you download this SFX file and the and you create this config file was just plain text file You can now create these exes for Windows on your Linux side without having to open up windows Obviously, you'd want to go and test it on a Windows machine But once you create your installer to your basically your batch file It should stay pretty much the same so you can update it without having to go into Windows If you don't want to although like I said, it's always good to test it So that's one plus another plus using a self-extracting zip file like this as you're executable And I think the same would be if you made a self-extracting zip file with something like win-zip is that if you're in Linux You could in most cases extract that as a zip file So if I was to give this exe file to someone on Linux They don't need to install wine or anything They could just extract it with their archive manager or whatever zip application They have and they would then have this folder and they can click on the HTML file in it and it would open up in their web browser So once again, not really getting that application field because it's opening up in a window But it is there as an option people can open it up and at least pick it apart if they want to So those those are some pluses to this technique Once again, some of you are going. Oh, you're doing it the hard way. You're doing it the hard way There's there's GUI applications. Well, you know what? GUI applications can't automate stuff once I've done this once I can write a script that would automate it and I could Write a shell script in Linux that would create this exe file and something for Linux And maybe something cross-platform all with one click every time I modify the program boom So I mean You this may seem more difficult to some people but people who know what they're doing It's actually a lot simpler once you get it set up. It takes a little more setup, but easier to do So that is one way of creating a self-extracting zip file a self-extracting exe on Windows or for Windows whether you're on Windows or not. You can do this from any operating system and But I'll show you another way that is perhaps a simpler way with tools that are built into Windows already that you may not know about And again, like I said, I know I'm probably gonna get a lot of comments There are a lot of programs out there for making Self-extracting exe files and installers. I'm not saying this is the best. I'm just saying this is the one I use It's the smallest because a lot of those are large applications that you have to install these big old Applications and have all these settings and I really don't care about them. I just want to run my program So it's just one option. I'm not saying it's necessarily better than others just better in certain situations I'm just trying to get that out of the way so I don't get all these these hate comments because you get those on YouTube anyway, so I hope you found this tutorial useful and I'll once again the next video will show you a simpler way using built-in tools, although It's simpler depending on what you're doing. So I thank you for watching and I hope that you have a great day Please visit my website filmsbychrist.com. That's Chris of the K There should be a link in the description and once again, I hope that you have a great day You