How to determine if a Python script is being run right after startup on Windows

Ryan George ragmanme at gmail.com
Tue Sep 7 04:10:14 EDT 2010


Hello Stephen,

Thanks for the prompt response!

>How would you, a human being, determine if the program was being run directly after startup?

I'm not going to claim that I am a computer systems expert; I don't
know a whole lot about what goes on in the Windows start up. I know
services and programs are started, Internet connections are made, and
connections to devices on your computer are tested. However, these are
all things that could happen at any time (programs: obviously;
Internet could disconnect; unplugging or plugging in a mouse, for
example). That's why I came here. Maybe someone knew something I
didn't.

I know you're trying to get me to come to my own conclusion of my own
accord, but I have been attacking this problem for 8 hours. If the
answer was within my knowledge, I believe would have discovered it by
now.

>What counts as "directly"? Within 10 seconds? Before any other program with a GUI? Before *any* other program, including background processes? Before the Windows desktop loads?

Maybe I should have made my purpose clearer. What I want the program
to do is perform its normal function (ie: swap your wallpaper with a
random one from a given directory) automatically after Windows
completely starts up, and then exit so as not to remain in memory.
With this new information, the answer to all of these questions should
be obvious. Since it depends on calls to the Windows API, this program
should be one of the last things to start, if not THE last thing.

>As far as you know, it SHOULD work? How about trying it and finding out?
Again, I probably should have been clearer. This functionality DOES
work. The program will swap the wallpapers, then exit. The only thing
I haven't tested is if it will work at start up, which would have
required a reboot of my computer, something I really didn't want to
have to do. I was in the process of coding other, more critical
features with around 20 different tabs opened in Firefox, as well as
participating communications with someone who was designing a logo for
me.

I will be testing it next time I boot my computer.

>In any case, it sounds to me that what you need is two programs, one which automatically sets the wallpaper at startup, and a second that is a GUI.

Yes, that is an option. However, my previous wallpaper cycler was able
to do what I am describing without two separate programs and I have
just discovered how. It was a switch on the executable that isn't
present when you try to run the program normally. This was probably
the first thing I should have looked into and I don't know why I did
not.

As long as I can pass variables through a command line when executing
a Python script, I see no reason why this shouldn't work. This
technically isn't the system letting the program know that it is
running after a start up, but rather a user telling a program that "I
am running you after a start up." Little bit of a different approach,
but hey, whatever works right?



More information about the Python-list mailing list