' 
'	Lists the sub keys and values of a given registry key
'
'	cscript regList.wsg HKLM\Software
'
'	Will Yield:
'
'	{
'		"hklm\software": { 
'			"keys": [ .. array of sub keys .. ], 
'			"values": { 
'				"moo": { 
'					"type": "REG_SZ", 
'					"value": "bar"
'				}
'			}
'		}
'	}
<job id="list">
	<script language="VBScript" src="util.vbs" />
	<script language="VBScript" src="regUtil.vbs" />
	<script language="VBScript">		
		CheckZeroArgs("usage: cscript regList.wsf architecture regpath1 [regpath2] ... [regpathN]")
		DetermineOSArchitecture()
		LoadRegistryImplementationByOSArchitecture()
	
		Write "{"
		For v = 1 To args.Count - 1
			if (v > 1) Then
				Write ","
			End If
			
			Write """" & JsonSafe(args(v)) & """: "
			
			ParseHiveAndSubKey args(v), constHive, strSubKey

			if IsNull(constHive) Then
				WriteLineErr "unsupported hive " & args(v)
				WScript.Quit 25122       
			End If

			ListChildrenAsJson constHive, strSubKey
		Next
		Write "}"
	</script>
</job>