3 # tool to manipulate a remote registry
4 # Copyright Andrew Tridgell 2005
5 # Copyright Jelmer Vernooij 2007
6 # Released under the GNU GPL v3 or later
11 options = GetOptions(ARGV,
14 "POPT_COMMON_CREDENTIALS",
16 if (options == undefined) {
17 print "Failed to parse options"
21 print "Usage: %s <BINDING> [path]" % sys.argv[0]
24 binding = options.ARGV[0]
27 print "Connecting to " + binding
28 status = reg.connect(binding)
29 if (status.is_ok != true) {
30 print("Failed to connect to " + binding + " - " + status.errstr + "\n")
34 def list_values(path):
35 list = reg.enum_values(path)
36 if (list == undefined) {
39 for (i=0;i<list.length;i++) {
41 printf("\ttype=%-30s size=%4d '%s'\n", reg.typestring(v.type), v.size, v.name)
42 if (v.type == reg.REG_SZ || v.type == reg.REG_EXPAND_SZ) {
43 printf("\t\t'%s'\n", v.value)
45 if (v.type == reg.REG_MULTI_SZ) {
47 printf("\t\t'%s'\n", v.value[j])
50 if (v.type == reg.REG_DWORD || v.type == reg.REG_DWORD_BIG_ENDIAN) {
51 printf("\t\t0x%08x (%d)\n", v.value, v.value)
53 if (v.type == reg.REG_QWORD) {
54 printf("\t\t0x%llx (%lld)\n", v.value, v.value)
60 list = reg.enum_path(path)
61 if (list == undefined) {
62 println("Unable to list " + path)
66 count = count + list.length
67 for (i=0;i<list.length;i++) {
69 npath = path + "\\" + list[i]
74 count = count + list_path(npath)
85 reg.create_key("HKLM\\SOFTWARE", options.createkey)
87 print "Failed to create key"
89 printf("Listing registry tree '%s'\n", root)
90 count = list_path(root)
92 println("No entries found")