I developed a program I think has potential, but don't want the end user to a) have to download python and b) steal my code. How would I turn it the .py of my script into a .bat or .exe so my end user can run it?

Dani AI

Generated

If your goals are (a) no Python install for users and (b) less casual access to your code, an EXE is the right target. A .bat still relies on an interpreter and leaves source files easy to read. If you truly want a .bat, use Python’s official Windows embeddable distribution: unzip it next to your app and have the batch file call the bundled python.exe. For example:

@echo off
setlocal
set RUNTIME=%~dp0runtime
"%RUNTIME%\python.exe" -m yourpackage %*
endlocal

This runs without a system-wide Python install; the docs even call out the “batch file” approach. It does not obfuscate code. See “The embeddable package.” docs.python.org/3.14/using/windows.html#the-embeddable-package.

For a true EXE, tools that work well today:

On protection: as and hint, no packager is a DRM system. PyInstaller bundles bytecode that can, in principle, be decompiled; it is fine for distribution but not for hiding secrets. If IP protection really matters, push sensitive logic into a compiled extension (C/Rust) or a server API, and treat any “encryption” or obfuscation as deterrence only. pyinstaller.org/en/v6.1.0/operating-mode.html#hiding-the-source-code

Nice extras: if you prefer an installer that bundles Python without freezing, Pynsist builds a Windows installer using the embeddable runtime. pynsist.readthedocs.io

Recommended Answers

All 6 Replies

You can use Py2exe to turn the code into an Windows executeable

http://www.py2exe.org/

Look into that.

tried both that and pyinstaller, I would like it as a .bat

tried both that and pyinstaller, I would like it as a .bat

Why would you want it in a .bat file? Turn it into an EXE.

If you want to turn it into a .bat you have translate the code into Batch.

Ok any other programs that are easy to use?

Probably the simplest way to make it a .bat is to make an exe that will write a .bat, execute the .bat, then delete the .bat.

In short, if you plan on distributing in windows, make it an exe. py2exe is the standard from what I understand. Your other options are here:

Im sure there are others.

interesting,thanks for the information :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.