Windows.  Viruses.  Notebooks.  Internet.  office.  Utilities.  Drivers

We'll consider creation.exe using the py2exe module library. This requires Python 3.4 and below.

If you have a higher version of Python installed, try using (below)

In this example, we will look at creating an .exe with an example Python3.4.

First of all, you need to create a virtual environment for Python3.4. In this example, we will name myenv, you can choose any other name, but do not forget to make the appropriate changes.

Type the following commands in the terminal:

>py -3.4 -m venv myenv > myenv\Scripts\activate.bat

IN command line prefix will appear myenv, which means that the virtual environment named myenv is loaded. All teams Python will now use the new virtual environment.

Now let's install py2exe(https://pypi.python.org/pypi/py2exe~~HEAD=dobj) in our virtual environment:

>pip install py2exe

And finally, to create a single EXE file, in our virtual environment we execute the command:

>python -m py2exe.build_exe hello.py -c --bundle-files 0

(replace hello.py to the name of your script. If the script is located in another folder, then you need to use the full path to your script, for example, C:\Projects\Python\ hello.py). This will create a DIST folder which contains the executable. For quick access to it, type in the terminal:

> explorer dist

You will see the path to the folder where the EXE file is located.

Note: When executed, a window will open and disappear as quickly as it appeared.
This happens because operating system automatically closes the terminal, in which console program finished.
To change this situation, you can add the line

> input ("Press to exit...")

at the end of the file Python. The interpreter will wait for user input, and the window will remain open until the user presses the enter key.

You can study the usage in detail py2exe in the documentation on the module page: https://pypi.python.org/pypi/py2exe
Exiting the virtual environment is done with the command

>deactivate

Method 2

Through command Windows line install pyinstaller:

>pip install pyinstaller

On the command line, go to the folder where the file is located

CD c:\...

Then at the command line we type the command

Pyinstaller --onefile example.py

Instead of example.py use the name of the file from which you want to create an exe file.

In a couple of minutes everything is ready! Most likely, the exe file will be located in the created subfolder dist

Content
1.How to compile EXE
1.1 Compilation technology
1.2 Related files
2.What you need to include in EXE

1.How to compile EXE
1.1 Compilation technology
Epigraph:
"Oh yes Pushkin, oh yes..."
A.S. Pushkin

The technology for compiling an EXE in Visual FoxPro is quite simple. We will not be distracted by such extreme methods as typing in the command window commands like BUILD PROJECT, BUILD APP, BUILD EXE , but we will limit ourselves to the conveniences provided by the VFP graphical interface.
So, to create an EXE, we need to press the button in the project manager "BUILD...". Selecting the option in the dialog box that opens Win32 executable / COM server (EXE) we press OK. ALL. ;-)
"How is everyone?" - you ask - "And specify under what name to save the file?"
I agree ... It must be specified, otherwise everything is down the drain.
By the way, I think it would be useful to remind you that in order for the compilation process to be successful, you need to fill the project manager with your program files, one of which must be as main (in the project manager, the name of this file is in bold), i.e. . file to be executed first. By default, the first program file (*.prg) or form file (*.scx) included in the project is set as the main program.
In general, everything is quite simple! Just..?
Now for the sad...

1.2 Related files
Epigraph:
"... and you turn it on - it doesn't work!"
M. Zhvanetsky

All the twists and turns of the application compilation stage are already over, and you, proud of the consciousness of your own superiority over mere mortals, rush to the customer with leaps and bounds, install your application, simultaneously describing to him (the customer) how everything will be cool now, and counting in your mind which screw you need to buy what would be left for beer, suddenly you stumble upon the fact that your super-duper program does not make a fuss. Sad. It's a shame. And most importantly, you won’t have a new winchester or what you planned to buy there for yourself with a fee ...

The thing is that the .exe compiled by us is not a self-sufficient executable file. This pseudo-executable needs support libraries (.dll) to work properly. I will not go into much discussion about this, but simply give the names of the files necessary for the normal operation of the application.
In principle, up to version 6 inclusive, you can use the standard Setup Wizard, who prescribes everything on his own, and in subsequent - InstallShield(or other installer).
All the files below are the minimum required set of files for various versions VFP (according to):

VFP 8.0 msvcr70.dll, vfp8r.dll, vfp8rrus.dll, gdiplus.dll VFP 7.0 msvcr70.dll, vfp7r.dll, vfp7rrus.dll VFP 6.0 vfp6r.dll, vfp6renu.dll , vfp6rrus.dll VFP 5.0 vfpole50.dll, vfpodbc .dll, vfp500.dll, vfp5rus.dll, Foxpro.int
The above set of libraries must be placed in the program directory or in the Windows system directory. For various Windows versions these directories are different:

Win9x, WinMe c:\Windows\SYSTEM WinNT,Win2000,WinXP c:\Windows\SYSTEM32

2.What you need to include in EXE
Epigraph:
"To include or not to include?"
drunk electrician

All of the following is the personal opinion of the author, which you can neglect. But when doing it your way, remember: banging your head against a concrete wall is much more painful than taking advantage of the breach made before you.
By default, the finished .exe includes all the files necessary for the application to work - programs, forms, menus, libraries, classes, etc. except for database files and tables (such files can be recognized by the crossed out circle next to the file name in the project manager). All files included in the .exe will become unmodifiable (read-only) after compilation. It is clear that table files (*.dbf) should not be included because they are subjected to constant data modification and addition operations, but sometimes there are cases when it is necessary to hide some static data from the user, but provide access to them by the program itself. There is no better place than the "insides" of an exe-file.
It is also quite common when you need to "find", or temporarily, change the report file, or when we have a whole set of reports that are unique for each user. Well, really imagine: ten operators and ten reports each, and all this in *.exe. the only way out in this situation is to exclude these reports from the final file and ship them with the application.
In any case, the decision on which files to exclude and which to leave is up to you.

Everything, the beer is over, we must go to the deli.

Sincerely, Vladislav Kulak

Content:

In this article, you will learn how to create a simple EXE file on a Windows computer, as well as how to create an exe container that can be used to run the executable file on another computer. EXE files are used to install programs or add files to a computer under Windows control. To create an EXE file, you need to use the IExpress system utility.

Steps

Part 1 How to create an EXE file

  1. 1 Open the Start menu.
  2. 2 In the Start menu search bar, type notepad. So you will find the Notepad program.
  3. 3 Click the Notepad icon. It looks like a blue notepad and sits at the top of the start menu.
  4. 4 Enter the program code for the file. Enter the code line by line, or copy and paste it into Notepad (if you already have the code ready).
    • If you don't know how, ask someone else to do it.
    • Also, the program codes of the simplest EXE files can be found on the Internet.
  5. 5 Click File. This menu is located in the upper left corner of the Notepad window. A dropdown menu will open.
  6. 6 Click Save As. This option is in the "File" drop-down menu.
  7. 7 Open the "File Type" drop-down menu. You will find it at the bottom of the window.
    • The current "File Type" menu option should be " Text Documents(*.txt)".
  8. 8 Click All Files. This option is in the drop down menu.
  9. 9 Enter a name for the EXE file. In the "File name" field, enter a name, and then enter the extension .exe . This will save the file as an EXE file.
    • For example, if the file will be called "bananas" (bananas), enter bananas.exe .
  10. 10 Select the folder where the EXE file will be stored. To do this, click on the corresponding folder in the left part of the window.
  11. 11 Click Save. This button is located in the lower right corner of the screen. This will save the EXE file in the selected folder.

Part 2 How to create an installation EXE file

  1. 1 Open the Start menu. To do this, click on the Windows logo in the lower left corner of the screen.
  2. 2 In the start menu search bar, type iexpress . This is how you find this utility.
    • Enter iexpress in full.
  3. 3 Click the iexpress utility icon. It looks like a gray cabinet and is at the top of the start menu.
  4. 4 Check the "Create new Self Extraction Directive file" option. It is in the middle of the page. This option should be checked by default; otherwise, select it.
  5. 5 Click Next. This button is located in the lower right corner of the window.
  6. 6 Check the "Extract files only" option. It is in the middle of the page.
  7. 7 Click Next.
  8. 8 Enter a name for your EXE file. Do this in the text box in the middle of the window, and then click Next.
  9. 9 Think of a window with a request. If you want the user to confirm that they want to run the EXE file, check the "Prompt user with" option and enter the confirmation prompt text. Otherwise, click Next.
    • When the user runs the EXE file, a window will open with the text you entered (if you selected the prompt option).
  10. 10 Think of a window with a license agreement. If you want text to be displayed on the screen license agreement, check the "Display a license" checkbox, then click "Browse" to select the document with the text of the license agreement, and then click "Open". Otherwise, click Next.
  11. 11 Click Add. This button is in the lower middle of the window. A new Explorer window will open, allowing you to select the files to be included in the installation EXE file.
    • The files included in the installation EXE will be installed when the user runs the EXE.
  12. 12 Select the files to be included in the EXE file. Click on the folder with files on the left side of the Explorer window, and then select the desired files; to do this, press left key mouse and drag the cursor over the desired files.
    • You can also select files one at a time; to do this, hold down ^ Ctrl and click on each desired file.
  13. 13 Click Open. This button is located in the lower right corner of the window. This will add the files to the installation EXE file.
    • If you need to add more files, click "Add" again and repeat the above process.
  14. 14 Click Next.
  15. 15 Check the "Default" box, and then click Next. It is located at the top of the window.
  16. 16 Think of a window with a closing message. This message appears on the screen when the EXE file installation process is completed. Check the "Display message" box, then enter the message text, and then click "Next".
    • If you don't want the final message to be displayed on the screen, just click Next.
  17. 17 Add the program to be installed. This is the program in the EXE file that was created earlier. Click Browse, open the file folder, click on it and click Save.
    • If you want, check the "Hide File Extracting Process Animation from User" checkbox to setup file worked without unnecessary visual effects.
  18. 18 Click Next three times. An EXE installation file will be created. The time for this process depends on the number of files you included in the installation EXE file.
  19. 19 Click Done. This button is located at the bottom of the window. The EXE installation file will be saved and ready to go.
  • You don't need an EXE installer to run an EXE file, but an EXE installer will install an EXE file and any ancillary items (such as a "ReadMe" file, folders, and so on).

Warnings

  • If you don't know how to code an EXE file, ask someone who knows how to program to do it.

Surely many of you at least once in your life came across an archive with the extension .exe, not rar or even zip, but exe. The beauty of this archive is that it is self-extracting and does not require the installation of additional programs. Many people think that in order to create this kind of archive, some specific knowledge or programs are required, but I dare to assure you that this is not so. EXE archives are created using one of several of the most popular archivers: WinRar and WinZip.

You probably have one of these two archivers installed on your computer, so you can safely start practicing right away. If there is no archiver at all, then you can safely install 7-zip, because it is free and freely distributed on the Internet. We will start with this archiver.

And so, we prepare a folder with files that needs to be archived and click on it right click mice. Finding an item like 7-Zip

We have another sub-menu popping up, from which we must select the item "Add to archive..."

A window opens with us, we are looking for the section "Options", in the options item "Create SFX archive" we set a bird in front of him. Now we pay attention to the topmost field, where is the name of our future archive. We have added the .exe extension. By the way, the name of the archive can be changed. You can also specify the location where you want to save it. In principle, you can play around with the other options, but they do not affect the type of archive. You can set the maximum compression level to keep the archive size as small as possible.

Now you can click on the "OK" button.

This is the file I have on my desktop:

Now let's figure out how to create exactly the same archive, but with the help of WinRar.

In the same way, right-click on the folder and select the item "Add to archive":

In the window that opens, in the "General" tab, you need in the section "Backup Options" put a bird in front of the item "Create SFX archive". We put any method of compression. I chose Good.

Click on the button "OK".

This is the resulting archive:

Here we have considered several ways of how to create self extracting exe archive.

And also watch a video on the topic:

Rate article:

homelisp(at least in the proposed version) is not capable of compiling Lisp code into microprocessor instructions. Therefore, to create stand-alone executable files, a technology is used that can be tentatively called pseudo EXE.

The essence of this technology is as follows.

In delivery homelisp includes a stub executable that contains the kernel homelisp. The size of this file is about two hundred kilobytes. When creating an EXE file, a copy of the stub file is first made with a name that the developer specifies. All further manipulations are performed with the created copy, which we will call further target file.

Assume that a developer has written and uploaded a set of features that together make up application. When creating an EXE file, all the functions chosen by the developer are added to the "tail" of the target file. In addition to these functions, the "tail" of the target file is written so-called. start S-expression, as well as user-defined environment settings homelisp(sizes of internal stacks, number of dynamic objects, etc.)

When the target file is launched, control is first received by the kernel initialization program homelisp, which then reads all user-saved functions from the file and loads them into the Lisp environment. After that, the control receives the block starting S-expression, and the program provided by the developer starts to be executed.

Let's consider the process of creating an EXE file using a simple practical example: we will create a dialog program that will calculate greatest common divisor two integers using the Euclid algorithm. This example is not so useless: since homelisp works with integers of unlimited bitness, writing a similar example in any common programming environment (VB, C ++, Delphi) would require noticeable effort ...

Function *GCD has the following form:

(defun *gcd (x y) (cond ((eq x y) x) ((greaterp y x) (*gcd y x)) ((eq (remainder x y) 0) y) (T (*gcd y (remainder x y))) )) ==> *gcd (*gcd 655 72) ==> 1 (*gcd 655 75) ==> 5 (*gcd 65536 4096) ==> 4096

Call examples show the functionality of the function. Next, you need to create a dialog shell to call this function. In the simplest case, this shell can be organized as follows:

Request (via function ASK) the first operand;

Request for the second operand;

Calculation of the result;

Displaying the result with a function SAY ;

Let's write a defining expression for the function GCD-1, which will implement the above algorithm:

(defun GCD-1 nil (prog (a1 a2) (setq a1 (str2fix (Ask "Enter first operand"))) (setq a2 (str2fix (Ask "Enter second operand"))) (TRY (say (fix2str (* gcd a1 a2))) EXCEPT (say "Error!"))))

Note that the result of the call ASK has type STRING, and the function *GCD requires operands of type FIXED. Therefore, before assigning user-supplied values ​​to local variables, a1 And a2, these values ​​should be converted to type FIXED(what are function calls for? STR2FIX).

Further, since an interactive program intended for the end user is being prepared, provision should be made for possible mistakes. That is why the calculation of the greatest common divisor is done critical piece of code with a function call TRY If the calculation fails, the program will not "crash", but the message "Error!" will be displayed.

If you execute the function GCD-1 from the development environment, then the query window for the first operand will be displayed first:


The user enters the first operand and presses the button OK; the second operand query window appears:


The user enters the second operand, presses the button OK and gets the result:


Now let's build based on the debugged function GCD-1 executable. To do this, while in the development environment, select the main menu item EXE file or click the button on the toolbar with the following icon:


In both cases, the EXE build window will open:



To create an EXE file, follow these steps:

Set the name of the EXE file. The name (and path) of the future EXE file is specified in the combined input field in the upper left corner of the EXE file creation form. The name and path can be set manually, or you can click the "..." button and select the directory and name using the standard dialog Save as. The file is created by default. noname.exe in the current directory.

In the input area "Starting S-Expression" you must specify the code from which the execution of the future application will begin. The starting S-expression can be a function call. If you want to specify a starting S-expression consisting of several calls, then these calls should be "enclosed" in PROG- design.

The above steps are the minimum required. Additionally, the user can additionally do the following:

In the list headed "Functions, Constants, Variables", clear the checkboxes for objects that are not required to run the application. This event will slightly increase the speed of application execution;

Change the values ​​of the settings in the list located in the upper right corner. The sequence of actions when replacing parameter values ​​will be described below;

Uncheck the box "Show dispatcher form at startup". If this checkbox is left checked, then when the application starts, a special control room form. This form can be given a title (in the corresponding input field). Using the dispatch form is handy when debugging.

Check or uncheck "Notify me when completed". If this box is checked, a message will be displayed before the application terminates.

The window for creating an EXE file with the minimum required set of parameters may look like this:



Next, you need to click the button with the green check mark. If the ordered EXE file already exists, homelisp You will be prompted to confirm that the file will be overwritten or set a new name. After that, at successful completion, the following message is displayed:


You can make sure that an EXE file has appeared in the current directory gcd-1.exe, at the start of which the described dialog with the user occurs.

If, when creating an EXE file, check the box "Display dispatcher form at startup" and set the title of the form:


Then, when the resulting EXE file is executed, a dispatcher form of the following form is displayed in the upper right corner of the screen:


When you select the Start menu item (or press the appropriate button below), the application starts running. After the application terminates, the dispatcher form remains on the screen, allowing the application to be launched multiple times. To complete the application, select the "Exit" menu item (or press the button below).

If an error occurs during the execution of the application with the dispatcher form, then information about the error is displayed in the output area, which is normally hidden. For example, if you make the start S-expression a call to a non-existent function (unknown), then when executed, the following picture will appear:


Using the dispatcher form allows you to forcibly stop the execution of the application. To do this, use the "Stop" menu item and the button located below (both the menu item and the button are active only while the application is running). If you set, for example, the calculation of the factorial of a sufficiently large number as a starting expression, then you can see the menu item and the stop button:


If you press "Stop" during execution, the program execution is interrupted:


The main menu item "Windows" of the dispatch form (and the corresponding command button) will be active if at least one graphical window is created during the application execution. When you select "Windows" (or click on the button below), the graphic window manager is called.

The mode of building EXE files with a dispatcher form is designed to facilitate application debugging. If you do not use the dispatcher form, then the developer himself will have to manage the graphic windows, and in the event of an application "hanging" to remove it, you will have to use the OS task manager.

If you need to change the value of any setting parameter (stack size, number of tokens, etc.), you must click on the required line in the "Parameters" list. The numerical value of the corresponding parameter will be transferred to the input area below the list:



As second example of creating an EXE file, consider the previous problem (calculating GCD), but with a windowed GUI. To do this, we will create a dialog (as described), on the form of which we will place three labels, three input fields and two buttons. Let's assign a handler procedure to one of the buttons, in which we calculate the GCD of the numbers entered in the first and second input fields and enter the calculated GCD into the result field. The second button click handler will close and destroy the dialog. The dialog form with controls may look like the following:


The code generated by the designer might look like this:

(prog nil (dlgCreate "_Dlg_ 419 233 "Greatest Common Divisor:") (dlgAddControl "_Dlg_ "_LBL_1 _LABEL 14 15 100 21 "("Tahoma" 14.25 1 0 0) "First:" 0 &H80000012 &H8000000F) ( dlgAddControl" _Dlg_ "_TXT_1 _TEXT 155 13 248 31 "("Tahoma" 14 1 0 0) "" 0 &H80000008 &H80000005) (dlgAddControl "_Dlg_ "_LBL_2 _LABEL 12 59 133 26 "("Tahoma" 14.25 1 0 0) "Second: " 0 &H80000012 &H8000000F) (dlgAddControl "_Dlg_ "_TXT_2 _TEXT 156 56 247 31 "("Tahoma" 14 1 0 0) "" 0 &H80000008 &H80000005) (dlgAddControl "_Dlg_ "_LBL_3 _ LABEL 13 101 127 27 "("Tahoma" 14, 25 1 0 0) "Н.О.Д." 0 &HFF &H8000000F) (dlgAddControl "_Dlg_ "_TXT_3 _TEXT 157 98 247 31 "("Tahoma" 14 1 0 0) "" 0 &HFF &H80000005) (dlgAddControl "_Dlg_ "_BUT_1 _BUTTON 24 148 180 50 "("Tahoma" 8.25 1 0 0) "Compute") (dlgPutPicture "_BUT_1 7) (dlgAddControl "_Dlg_ "_BUT_2 _BUTTON 213 149 180 50 "("Tahoma" 8.25 1 0 0) "Close") (dlgPutPicture "_BUT_2 36) // // CLICK event handler for button _BUT_2 // (defun _BUT_2_Click Nil (prog Nil (dlgHide "_DLG_) (dlgDestroy "_DLG_) (gc))) // // Purpose of procedure -events _BUT_2_Click to control _BUT_2 // (dlgSetEvent "_BUT_2 "_BUT_2_Click) // // CLICK event handler for button _BUT_1 // (defun _BUT_1_Click Nil (prog (a1 a2) (setq a1 (str2fix (dlgGetText "_TXT_1))) (setq a2 (str2fix (dlgGetText "_TXT_2))) (TRY (dlgPutText "_TXT_3 (fix2str (*gcd a1 a2))) EXCEPT (dlgPutText "_TXT_3 "Error!!!")))) // // Destination of the _BUT_1_Click event procedure control _BUT_1 // (dlgSetEvent "_BUT_1 "_BUT_1_Click) // // Display dialog _Dlg_ // (dlgShow "_Dlg_))

In order to build an EXE file, you need to load a function into the Lisp environment and write a start expression to display the dialog. The easiest way is to "load" the above PROG-construct to function MAIN without parameters. Then the starting S-expression for running the EXE file will be the call (main). So, if you load the following functions into the Lisp environment:
// // Finding the greatest common divisor // (defun *gcd (x y) (cond ((eq x y) x) ((greaterp y x) (*gcd y x)) ((eq (remainder x y) 0) y) (T (*gcd y (remainder x y))))) // // Dialog display program _Dlg_ // (defun main nil (prog nil (dlgCreate "_Dlg_ 419 233 "Greatest Common Divisor:") (dlgAddControl "_Dlg_ "_LBL_1 _LABEL 14 15 100 21 "("Tahoma" 14.25 1 0 0) "First:" 0 &H80000012 &H8000000F) (dlgAddControl "_Dlg_ "_TXT_1 _TEXT 155 13 248 31 "("Tahoma" 14 1 0 0) "" 0 &H80000 008&H80000005) (dlgAddControl "_Dlg_ "_LBL_2 _LABEL 12 59 133 26 "("Tahoma" 14.25 1 0 0) "Second: "0 &H80000012 &H8000000F) (dlgAddControl "_Dlg_ "_TXT_2 _TEXT 156 56 247 31"( "Tahoma" 14 1 0 0) "" 0 &H80000008 &H80000005) (dlgAddControl "_Dlg_ "_LBL_3 _LABEL 13 101 127 27 "("Tahoma" 14.25 1 0 0) "N.O.D." 0 &HFF &H8000000F) (dlgAddControl "_Dlg_ "_ TXT_3_TEXT 157 98 247 31 "("Tahoma" 14 1 0 0) "" 0 &HFF &H80000005) (dlgAddControl "_Dlg_ "_BUT_1 _BUTTON 24 148 180 50 "("Tahoma" 8.25 1 0 0) "Compute") (dlgPutPicture " _BUT_1 7) (dlgAddControl "_Dlg_ "_BUT_2 _BUTTON 213 149 180 50 "("Tahoma" 8,25 1 0 0) "Close") (dlgPutPicture "_BUT_2 36) // // CLICK event handler for button _BUT_2 // (defun _BUT_2_Click Nil (prog Nil (dlgHide "_DLG_) (dlgDestroy "_DLG_) (gc))) // // Assigning the _BUT_2_Click event procedure to the _BUT_2 control // (dlgSetEvent "_BUT_2 "_BUT_2_Click) // // CLICK event handler for button _BUT_1 // (defun _BUT_1_Click Nil (prog (a1 a2) (setq a1 (str2fix (dlgGetText "_TXT_1))) (setq a2 (str2fix (dlgGetText "_TXT_2))) (TRY (dlgPutText "_TXT_3 (fix2str (*gcd a1 a2)) )) EXCEPT (dlgPutText "_TXT_3 "Error!!!")))) // // Assigning the _BUT_1_Click event procedure to the _BUT_1 control // (dlgSetEvent "_BUT_1 "_BUT_1_Click) // // Displaying the _Dlg_ dialog // (dlgShow "_Dlg_ )))

and then build the exe file gcd-2.exe by setting the following parameters:


That will work fully functional EXE file. You can run it and make sure that GCD considered correct:

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE: