r9568: updated the winreg js library for CreateKey, and add a --createkey
[samba.git] / source / scripting / bin / winreg
index 7845f1034c5a53adbaf2d7251f3582e820557a47..12f40f1155515967d0901700fb23781f3976a9c4 100755 (executable)
@@ -12,7 +12,8 @@ libinclude("winreg.js");
 var options = GetOptions(ARGV,
                         "POPT_AUTOHELP",
                         "POPT_COMMON_SAMBA",
-                        "POPT_COMMON_CREDENTIALS");
+                        "POPT_COMMON_CREDENTIALS",
+                        "createkey=s");
 if (options == undefined) {
        println("Failed to parse options");
        return -1;
@@ -61,6 +62,10 @@ function list_values(path) {
 
 function list_path(path) {
        var list = reg.enum_path(path);
+       if (list == undefined) {
+               println("Unable to list " + path);
+               return;
+       }
        var i;
        list_values(path);
        for (i=0;i<list.length;i++) {
@@ -83,6 +88,13 @@ if (options.ARGV.length > 1) {
        root = '';
 }
 
-printf("Listing registry tree '%s'\n", root);
-list_path(root);
+if (options.createkey) {
+       var ok = reg.create_key("HKLM\\SOFTWARE", options.createkey);
+       if (!ok) {
+               
+       }
+} else {
+       printf("Listing registry tree '%s'\n", root);
+       list_path(root);
+}
 return 0;