Windows CD autorun program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • M.E.Farmer

    #1

    Windows CD autorun program

    Hello all,
    I needed this and did a quick search around and didn't see any
    examples.
    I knew it had to be easy, and it was.
    So here it is a CD_Autorun program in python.
    It is very simple and without comments is only about 30 lines.
    Also included a setup.py at the end of the script so you can
    'compile' it easily.

    py>############ ############### ############### ############### ############
    py># CD_Autorun.pyw
    py># tested on windows 98, windows 2000
    py>############ ############### ############### ############### ############
    py># Why, you ask , because it was sorta easy and free ;)
    py># Really I just have fun writing my on tools and I
    py># needed a simple autoloader for a project I am working on.
    py># It is not full featured and guarnteed to have a few bugs.
    py>############ ############### ############### ############### ############
    py># 'compile' with py2exe or McMillan Installer
    py># All you need now is this and autorun.inf file on your cd
    py># You can run this first to generate your autorun file.
    py># Then you can edit at will, or leave default for index.htm
    py># To make a CD autorun under windows you have
    py># to have an autorun.inf file in top level of your cd.
    py># For autorun.inf syntax go to msdn or just google it.
    py>############ ############### ############### ############### ############
    py># We need few files to get going
    py># autorun.inf <-create with this program, run once
    py># CD_Autorun.exe <-create this with py2exe or McMillan Installer
    py># *.* <-any other files creted by py2exe or McMillan Installer
    py># CD_Autorun.ico <-name your cd icon this or edit autorun.inf
    py># index.htm or your_file <-your file
    py># Put them all in the top directory and edit your autorun.inf
    py># to your_file_name if you didn't already.
    py># then just use your favorite cd burning software and burn it.
    py># Put the disk back in the cd tray and it should
    py># autorun your program.
    py>############ ############### ############### ############### ############
    py>__version__ = '.1'
    py>import os, sys, traceback
    py>pathbase = os.path.split(s ys.executable)[0]
    py>autorun = os.path.join(pa thbase,'autorun .inf')
    py>if os.path.exists( autorun):
    py> try:
    py> if len(sys.argv) > 1:
    py> try:
    py> item = sys.argv[1]
    py> try:
    py> args = sys.argv[2:]
    py> except:
    py> args =[]
    py> path = os.path.join(pa thbase,item)
    py> args.insert(0,p ath)
    py> args = ' '.join(args)
    py> os.spawnl(os.P_ NOWAIT, path, args)
    py> except:
    py> try:
    py> os.startfile(pa th)
    py> except:
    py> os.starfile('in dex.htm')
    py> else:
    py> os.startfile('i ndex.htm')
    py> except:
    py> os.startfile('i ndex.htm')
    py>else:
    py> try:
    py> autorun_templat e = """[AutoRun]
    py>open=CD_Auto run.exe index.htm
    py>icon=CD_Auto run.ico
    py>"""
    py> autorun_file = open(autorun, 'wt')
    py> autorun_file.wr ite(autorun_tem plate)
    py> autorun_file.cl ose()
    py> except:
    py> traceback.print _exc()
    py>sys.exit(0)
    py>############ ############### ############### ############### ####
    py>## I prefer to use McMillan Installer
    py>## and use the onefile option, it just looks cleaner to me.
    py>## I will leave that for you to figure out.
    py>## It isn't hard.
    py>############ ############### ############### ############### ####
    py>## This is for py2exe.
    py>## Remeber you can use --icon to change the icon(win2k only?)
    py>############ ############### ############### ############### ####
    py>## setup.py py2exe
    py>############ ############### ############### ############### ####
    py># from distutils.core import setup
    py># import py2exe
    py># setup(name="CD_ Autorun",
    py># scripts=["CD_Autorun.pyw "])
    py>############ ############### ############### ############### ####
    py>## 2004 M.E.Farmer Jr.

Working...