Service Control
Hutchins, Mike
mhutchins at amr-corp.com
Fri Jan 31 08:55:54 EST 2003
Actually, I was a little caffeinated when I wrote this, hence all kinds
of bad form for someone requesting assistance.
I have a small script that kills computer browser services and changes
some reg keys. The only problem is that if it runs against a Windows XP
machine, it requires the machine name as an argument. Here is an
example:
This works against NT/W2K, but not XP
******************************begin**************************
aWS = string.replace(line, "\n", " ") # replace newlines by spaces
aReg = ConnectRegistry(aWS,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg,
r"SYSTEM\CurrentControlSet\Services\Browser\Parameters", 0,
KEY_ALL_ACCESS) # KEY_SET_VALUE doesn't work here
aValue1 = QueryValueEx(aKey, aDM)
aValue2 = QueryValueEx(aKey, aMSL)
win32serviceutil.StopService(aSvcName) # No machine name or variable
required here it knows it already
******************************end*****************************
This works for XP
****************************begin*****************************
aWS = string.replace(line, "\n", " ") # replace newlines by spaces
aReg = ConnectRegistry(aWS,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg,
r"SYSTEM\CurrentControlSet\Services\Browser\Parameters", 0,
KEY_ALL_ACCESS) # KEY_SET_VALUE doesn't work here
aValue1 = QueryValueEx(aKey, aDM)
aValue2 = QueryValueEx(aKey, aMSL)
win32serviceutil.StopService(aSvcName, aWS) # needs the actual name
of the machine as an argument
**************************************************************
So I sorta have it figured out, just not why it behaves like that..
Thanks, and in the future, I will try to ask all of my newbie questions
the way they should be asked. =:-)
More information about the Python-list
mailing list