Month: March 2016

Replacement DOS commands and PowerShell alternatives

Not really a post, more a note to myself about DOS commands that been removed

DELTREE has been replaced by RD /s /q

If using PowerShell

SET PATH=%PATH%;c:\somepath becomes $env:path += “;c:\somepath”


Creating an executable – cxfreeze

Despite its versatility, there are times when you want to run a script on a server (or a computer for that matter) but do not want to install Python. This is especially true for live servers. There are several solutions to create a stand-alone executable you can run; I’ll give a quick start to cx Freeze as the quick start is not at the start of documentation.

As with all good modules you can install with pip; it is named cx-Freeze in pip. It installs the main script into <<PythonInstallDir>>\Scripts called cxfreeze. However it omits the .py extension which is fine for a *nix OS but not for Windows.

Once installed the quickest way to create an executable from your Python script is to change into the Scripts directory and run the following command line (a single command in case of text wrap):

python cxfreeze x:\path\to\script\ --target-dir x:\path\to\target\folder

This will create the x:\path\to\target\folder with an executable  with the same name as your Python script, the main Python runtime dll and .pyd file (effectively a dll) for each additional Python script your program needs to run. These should be all the files you need to run on a machine without Python installed.

As with everything you need to test this in a suitable environment.