loading a symbol into microsoft xp registry by remote logon server

cwnewbe1@yahoo.com CWNEWBE1 at YAHOO.COM
Fri Feb 20 10:06:51 EST 2004


I would like to be able to add environment symbols to the Microsoft XP
registry.  I tried the example in the Python Cookbook by Orielly by
running the script locally and it worked fine.  Although I noticed
that even though the symbol showed immediatedly in the registry by
viewing with regedit but not via a new dos command console, thus, I am
forced to reboot to make it 'lock in'.  Is this normal?

My wish is to have the script invoked in the start-up script when a
person logs into a network, that, will populate the logging on
machines registry with the desired symbols.  The Python.exe is on
another server (not the password verification server).

I do not want to place python.exe on every machine that needs symbols
loaded.

The symbols do not get loaded when I login to the network server.

The network machine is a Windows NT server.

First, in the logon script located on the network server I map a drive
to the server containing the python.exe
      NET USE z: \\heimdall\

Then I next execute in the logon script the python script as:
       z:\python_2.3.2\python.exe  z:\QA\env.py

Do I need to use a drive letter mapping, or can I use a URL syntax in
NT?

Enclosed is the code I am executing in env.py, minus the imports:
What am I missing? 
Can this be done?
Do I have correct priviledges in the logon script at this time?

# ***************************************************
# Set a System Environment Symbol on a local machine
#   c : a computers name  \\theComputer
#   k : the symbol key
#   v : data payload of the symbol value
def setSystemRegistrySymbol(c,k,v):
    print "Setting symbol on machine: " + c + " with symbol : " + k +
"=" + v
    x = _winreg.ConnectRegistry(c,_winreg.HKEY_LOCAL_MACHINE)
    y = _winreg.OpenKey(x,
                        r"SYSTEM\CurrentCOntrolSet\Control\Session
Manager\Environment",
                        0,
                        _winreg.KEY_ALL_ACCESS)
    _winreg.SetValueEx(y,k,0,_winreg.REG_EXPAND_SZ,v)
          
    _winreg.CloseKey(x)
    _winreg.CloseKey(y)

machine = r'\\myMachinesName'

setSystemRegistrySymbol(machine,"QA_BUILD",'\\\\Heimdall\\Firmware\\QA\\')



More information about the Python-list mailing list