473,503 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(sys.executable)[0]
py>autorun = os.path.join(pathbase,'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(pathbase,item)
py> args.insert(0,path)
py> args = ' '.join(args)
py> os.spawnl(os.P_NOWAIT, path, args)
py> except:
py> try:
py> os.startfile(path)
py> except:
py> os.starfile('index.htm')
py> else:
py> os.startfile('index.htm')
py> except:
py> os.startfile('index.htm')
py>else:
py> try:
py> autorun_template = """[AutoRun]
py>open=CD_Autorun.exe index.htm
py>icon=CD_Autorun.ico
py>"""
py> autorun_file = open(autorun, 'wt')
py> autorun_file.write(autorun_template)
py> autorun_file.close()
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.

Jul 18 '05 #1
0 2348

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
5034
by: Ray5531 | last post by:
I'm looking for a good Freeware autorun maker for my C# application.Any suggessions? Thanks
17
6413
by: UJ | last post by:
Is there any way for a windows service to start a windows program ? I have a service that will need to restart a windows app if it needs to. TIA - Jeff.
9
1317
by: Miro | last post by:
Wondering if anyone here has come up with a different solution than I keep coming back to: Here is a thought and I just can't seem to come up with another solution other than to install my old...
2
1519
MrMancunian
by: MrMancunian | last post by:
Hi Everybody, We've got a virus problem in our department and the thing it does is always the same. It creates an autorun.inf in the root of every partition. When the partition is accessed (or...
0
6101
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Overview NOTE- This complete article on "Windows Autorun FAQs" applies theoretically to all Windows NT-based OSes till Windows Vista (and probably Vista's successors too)....
0
9188
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Description NOTE- If you are unfamiliar with the concept of autoruns, then read "Windows Autorun FAQs: Overview". Que-1: How can I safely remove or edit the autorun...
0
30175
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
0
9932
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.