summaryrefslogtreecommitdiff
path: root/testprogs/ejs/winreg.js
blob: 831528b05cb48f5a5f309e684ed4d91737b182f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env smbscript
/*
  test winreg calls from ejs
*/	

libinclude("base.js");
libinclude("winreg.js");

var options = new Object();

ok = GetOptions(ARGV, options,
		"POPT_AUTOHELP",
		"POPT_COMMON_SAMBA",
		"POPT_COMMON_CREDENTIALS");
if (ok == false) {
   println("Failed to parse options: " + options.ERROR);
   return -1;
}

libinclude("base.js");

if (options.ARGV.length != 1) {
   println("Usage: winreg.js <BINDING>");
   return -1;
}
var binding = options.ARGV[0];
reg = winreg_init();
security_init(reg);

print("Connecting to " + binding + "\n");
status = reg.connect(binding);
if (status.is_ok != true) {
   print("Failed to connect to " + binding + " - " + status.errstr + "\n");
   return -1;
}

function list_path(path) {
	var list = winreg_enum_path(reg, path);
	var i;
	if (list == undefined) {
		return;
	}
	for (i=0;i<list.length;i++) {
		var npath = path + "\\" + list[i];
		println(npath);
		list_path(npath);
	}
}

var trees = new Array("HKCR", "HKLM", "HKPD", "HKU");

for (i=0;i<trees.length;i++) {
	printf("Listing tree '%s'\n", trees[i]);
	list_path(trees[i]);
}

print("All OK\n");
return 0;