Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Noob needs help with code
#1
Hey everyone, I am a total noob when it comes to programming but I try when asked. I am currently looking at a new software package and it uses python to push out scripts. I tried to make my own script to change the startup type from Automatic to Automatic (delayed), but even though the software program shows that the script was successful the service type never changes. I was able to put together most of the script from here "https://stackoverflow.com/questions/15128225/python-script-to-read-and-write-a-path-to-registry (thanks to hugo24) and then pieced some other parts together. At first it was failing at various points (line 5, 6, etc.) but I was able to research and figure out those errors.

Can someone help me determine why the script is showing success but not doing anything? Thank you in advance.

Phil Wall

def set_reg(name, value):
	try:
		winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\*Service*", 0, winreg.KEY_ALL_ACCESS)
		key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\*Service*", 0, winreg.KEY_ALL_ACCESS)
		winreg.SetValueEx(key, Start, 0, winreg.REG_DWORD, 0x00000001)
		winreg.CloseKey(key)
		return True
	except WindowsError:
		return False

def get_reg(name):
	try:
		key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Services\*Service*", 0, winreg.KEY_ALL_ACCESS)
		value, regtype = winreg.QueryValueEx(key, name)
		winreg.CloseKey(key)
		return value
	except WindowsError:
		return None
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why isn't this code working ? (noob here) SuperSymmetry 1 2,370 Jan-12-2018, 11:23 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020