deleting registry keys and value

2005-11-18 Thread sdb1031
Hi,

I am trying to learn how to write, change and delete registry keys and
values of a remote computer via Python's _winreg module.  So far, I've
been able to programmatically create a value and read the value.
However, I am unable to figure out how to delete the value.  Using the
following code, I get the following output:

MyNewKey c:\winnt\explorer2.exe 1
Traceback (most recent call last):
  File "C:\Documents and Settings\sbriley.STAT\Desktop\testreg.py",
line 12, in
?
DeleteValue(aKey, r"MyNewKey")
WindowsError: [Errno 5] Access is denied

I have administrative access on the target machine and can delete the
key manually by connecting remotely using regedit.  Here's the code.
BTW,  does anyone know how to provide credentials to the remote system
if it has a different user/pass than the host system?  I don't believe
that ConnectRegistry() will allow this.

Thanks,

Steve

from _winreg import *
#create the key
aReg = ConnectRegistry("remotecomputer",HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
0, KEY_WRITE)
SetValueEx(aKey,"MyNewKey",0, REG_SZ, r"c:\winnt\explorer2.exe")

aReg = ConnectRegistry("remotecomputer",HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
KEY_ALL_ACCESS)
n,v,t = EnumValue(aKey,5)
#print out the key
print n, v, t
CloseKey(aKey)

aKey = OpenKey(aReg, r"SOFTWARE\Microsoft\Windows\CurrentVersion\Run",
KEY_ALL_ACCESS)
DeleteValue(aKey, "MyNewKey")

-- 
http://mail.python.org/mailman/listinfo/python-list


Including standalone="no" in XML declaration

2006-04-14 Thread sdb1031
I'm trying to learn about Python and XML.  I would like to be able to
add standalone="no" to my xml declaration when writing an xml file, but
I am unable to figure out how.  So far, I have the following code:

import xml.dom.minidom
doc2 = xml.dom.minidom.Document()
print doc2.toxml('iso-8859-1')

Which produces the following XML declaration:


However, my goal is to have the XML declaration look like the
following:


The following link mentions "standalone" as a Document class variable,
but I am unsure how to make this work or even if I am on the right
track.
http://epydoc.sourceforge.net/stdlib/private/_xmlplus.dom.minidom.Document-class.html#encoding

Any help would be greatly appreciated.

Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list