Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Newbie question: getting my program to run at startup on Windows

Reply
Thread Tools

Newbie question: getting my program to run at startup on Windows

 
 
Arjan Dikhoff
Guest
Posts: n/a
 
      02-10-2004
Hello, I'm new to this list.

I'm trying to get my program to run automatically at startup, but so far
no luck. I came as far as:

key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run ")

_winreg.SetValueEx(key, "earthclock", 0, _winreg.REG_SZ, os.getcwdu() +
"\\EarthClock.exe")
_winreg.CloseKey(key)

But I get "WindowsError: [Errno 5] Access is denied"

I'm probably doing something blatantly wrong. Does anyone know what it
is?

Arjan



 
Reply With Quote
 
 
 
 
Mark Hammond
Guest
Posts: n/a
 
      02-11-2004
Arjan Dikhoff wrote:
> Hello, I'm new to this list.
>
> I'm trying to get my program to run automatically at startup, but so far
> no luck. I came as far as:
>
> key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
> "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run ")
>
> _winreg.SetValueEx(key, "earthclock", 0, _winreg.REG_SZ, os.getcwdu() +
> "\\EarthClock.exe")
> _winreg.CloseKey(key)
>
> But I get "WindowsError: [Errno 5] Access is denied"
>
> I'm probably doing something blatantly wrong. Does anyone know what it
> is?


Keys are opened with 'read' access by default. Use:
key =
_winreg.OpenKey(_winreg.HKEY_CURRENT_USER,"SOFTWAR E\\Microsoft\\Windows\\CurrentVersion\\Run",
0, _winreg.KEY_ALL_ACCESS)

And it works fine.

Mark.

 
Reply With Quote
 
 
 
 
Miki Tebeka
Guest
Posts: n/a
 
      02-11-2004
Hello Arjan,

> key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
> "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run ")
>
> _winreg.SetValueEx(key, "earthclock", 0, _winreg.REG_SZ, os.getcwdu() +
> "\\EarthClock.exe")
> _winreg.CloseKey(key)
>
> But I get "WindowsError: [Errno 5] Access is denied"
>
> I'm probably doing something blatantly wrong. Does anyone know what it
> is?

As the docs say, the default access mask for OpenKey is KEY_READ. Try:
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run ",
sam=_winreg.KEY_ALL_ACCESS)

HTH.
Miki
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Program will not run, used to run, have reinstalled numerous times,no luck Boppy NZ Computing 15 01-24-2011 10:30 AM
Getting a Python program to run of off a flash drive? Abethebabe Python 8 05-09-2010 02:22 PM
need program to have Windows startup the same each time.... Gordon J. Rattray MCSE 1 07-01-2009 07:54 AM
getting a windows java program to run on a mac and different java version Eric Java 4 02-18-2004 06:45 PM
Open Program upon Windows 2000 Professional startup Bun Mui Computer Support 2 09-07-2003 07:30 PM



Advertisments