2 exec smbscript "$0" ${1+"$@"}
4 tool to manipulate a remote registry
5 Copyright Andrew Tridgell 2005
6 Released under the GNU GPL v2 or later
9 var options = GetOptions(ARGV,
12 "POPT_COMMON_CREDENTIALS",
14 if (options == undefined) {
15 println("Failed to parse options");
19 libinclude("base.js");
20 libinclude("winreg.js");
22 if (options.ARGV.length < 1) {
23 println("Usage: winreg.js <BINDING> [path]");
26 var binding = options.ARGV[0];
29 print("Connecting to " + binding + "\n");
30 status = reg.connect(binding);
31 if (status.is_ok != true) {
32 print("Failed to connect to " + binding + " - " + status.errstr + "\n");
36 function list_values(path) {
37 var list = reg.enum_values(path);
39 if (list == undefined) {
42 for (i=0;i<list.length;i++) {
44 printf("\ttype=%-30s size=%4d '%s'\n", reg.typestring(v.type), v.size, v.name);
45 if (v.type == reg.REG_SZ || v.type == reg.REG_EXPAND_SZ) {
46 printf("\t\t'%s'\n", v.value);
48 if (v.type == reg.REG_MULTI_SZ) {
51 printf("\t\t'%s'\n", v.value[j]);
54 if (v.type == reg.REG_DWORD || v.type == reg.REG_DWORD_BIG_ENDIAN) {
55 printf("\t\t0x%08x (%d)\n", v.value, v.value);
57 if (v.type == reg.REG_QWORD) {
58 printf("\t\t0x%llx (%lld)\n", v.value, v.value);
63 function list_path(path) {
64 var list = reg.enum_path(path);
65 if (list == undefined) {
66 println("Unable to list " + path);
71 for (i=0;i<list.length;i++) {
74 npath = path + "\\" + list[i];
85 if (options.ARGV.length > 1) {
86 root = options.ARGV[1];
91 if (options.createkey) {
92 var ok = reg.create_key("HKLM\\SOFTWARE", options.createkey);
94 println("Failed to create key");
97 printf("Listing registry tree '%s'\n", root);