The run-entry in win.ini
Introduction:
This document describes a way to auto-run a program when Windows is started. The simple way would be to add it to
the Autostart group. But if you want to make it invisible for the (average) user you can do it like it is describes below.
Structure of .ini-files
There is no such thing as a standard "file format" for .ini (initialization) - files, however Windows saves data in its
initialization-files using a standard structure. The data is sorted in sections. The beginning of a section is marked with
a kind of section-headline. This headline is the name of the section enclosed in brackets: [ and ]. For example
if the name of a section is "options", the section headline would be saved as "[options]". In every section there are
different entries, which specify the actual data. The format of a line which contains an entry is the following:
entry-name = value. For example Wallpaper=C:\WINDOWS\CLOUDS.BMP Every line in a given
initialization-file can be found with its section name and its entry name.
How to make Windows auto-run a program:
In the windows section of your win.ini file there is an entry named run. The windows-section
is on top of the file on most systems. You can specify every executeable file in the run-entry. Your win.ini may
look like this:
If you specify an executeable file after run=, it will be executed whenever Windows is started. For example run=winmine.exe
To write a program which sets the run-entry you have to use the API function WriteProfileString (actually you don't
have to but it is the easiest way). Below is a short explanation of this function.
BOOL WriteProfileString(lpszSection, lpszEntry, lpszString)
- LPCSTR lpszSection
- specifies the section which contains the entry to be modified.
- LPCSTR lpszEntry
- specifies the entry to be modified.
- LPCSTR lpszValue
- specifies the value to set the given entry to.
If you want to modifiy win.ini in a way that Minesweeper is executed whenever you are starting Windows, you have
to use the following function call: WriteProfileString("windows", "run", "winmine.exe").
Back to the main page
Copyright 1998 Stefan Hetzl. If you have questions or comments or have discovered an error,
send mail to [email protected]. You may forward this document or publish it on
your webpage as long as you don't change it and leave this notice at the end.