Generating custom Windows installers

  • Thread starter cesar.covarrubias
  • Start date
C

cesar.covarrubias

Hello,

I am working on creating an installer of a Python 3.2 application that we programmed. The end goal is to create an installer in which we can specify the install path, and create shortcuts in the Start Menu and Desktop. Ideally, we would like to give the users the option to create the Desktop or Start Menu shortcuts.

I was able to create a .msi file with the setup.py and install.py files below. This allowed me to specify the custom default path but not create the shortcut in the Start Menu.

Can anyone help me figure out what I'm missing?


setup.py
--------

from cx_Freeze import setup, Executable
import sys

productName = "ProductName"
if 'bdist_msi' in sys.argv:
sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName]
sys.argv += ['--install-script', 'install.py']

exe = Executable(
script="main.py",
base="Win32GUI",
targetName="Product.exe"
)
setup(
name="Product.exe",
version="1.0",
author="Me",
description="Copyright 2012",
executables=[exe],
scripts=[
'install.py'
]
)
-----------------------------------------

install.py
----------
import os
import sys
import win32com.client as w32client

shortcut_group_name = "Start Menu Dir"
shortcut_name = "Product Name"
shortcut_target = "http://www.microsoft.com"

sh = w32client.Dispatch("WScript.Shell")
p = sh.SpecialFolders("AllUsersPrograms")
assert(os.path.isdir(p))
p = os.path.join(p, shortcut_group_name)
if (not os.path.isdir(p)):
os.makedirs(p)
lnk = sh.CreateShortcut(os.path.join(p, shortcut_name + ".lnk"))
lnk.TargetPath = shortcut_target
lnk.Save()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top