Skip to content

Commit

Permalink
Sample code to create and read keys from Windows registries
Browse files Browse the repository at this point in the history
  • Loading branch information
dzupin authored and dzuro02 committed Feb 8, 2017
1 parent db069ce commit 8bbe99d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 6 additions & 4 deletions commandLine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

file = open('C:\CA\AionBRE\examples\Associate\Out.log', 'r')
print file.read()


exit()

#Linuxr
Expand All @@ -33,14 +31,18 @@
#Run econcatenated execution commnand
subprocess.call(cmdTestRoutine,shell=True)

#Example how to open and parse log file using shell command tail on Linux (If possible, use Python build-in file processing instead)
#Example how to open and parse log file using shell command tail on Linux (This is command-line output processing demo. If possible, use Python file open instead)
proc = subprocess.Popen(['tail', '-2000','/TEMP/Out.log'], stdout=subprocess.PIPE)
for line in proc.stdout.readlines():
print (line.rstrip())

#file = open('/TEMP/Out.log', 'r')
# print file.read()




#Scratchpad AREA
#Scratchpad AREA
# import os
#if os.name == 'posix' and sys.version_info[0] < 3:
# import subprocess32 as subprocess
Expand Down
12 changes: 12 additions & 0 deletions windowsRegistry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _winreg as wreg
# Create new registry key with subkey and new value - Reenable next 3 lines when this code is run for the first time
#key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject")
#wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'testsubkey')
#wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_SZ, 'testvalue')

key = wreg.OpenKey(wreg.HKEY_LOCAL_MACHINE, "Software\\TestCompany\\TestProject",0, wreg.KEY_ALL_ACCESS)
print ("Next line should output: testsubkey")
print (wreg.QueryValue(key, 'NewSubkey'))
print ("Next line should output: testvalue")
print (wreg.QueryValueEx(key, 'ValueName'))
key.Close()

0 comments on commit 8bbe99d

Please sign in to comment.