qiushang vor 1 Jahr
Ursprung
Commit
a6cc9e6210

+ 0 - 75
bin/ia32/vbs/ArchitectureAgnosticRegistry.vbs

@@ -1,75 +0,0 @@
-' Notes: wanted to implement this using a class but:
-' 1. No matter what I did I could not assign the result of GetObject to a private member
-' 2. It looks as if all methods were treated as subs from the outside world which is not good since 
-' some of these need to return a value
-'
-
-Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv")		
-
-Function SetStringValue(constHive, strSubKey, strValueName, strValue)	
-	SetStringValue  = private_oReg.SetStringValue(constHive, strSubKey, strValueName, strValue)	
-End Function
-
-Sub GetStringValue(constHive, strKey, strValueName, strValue)
-	private_oReg.GetStringValue constHive, strKey, strValueName, strValue
-End Sub
-
-Function SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-	SetExpandedStringValue = private_oReg.SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-End Function
-
-Sub GetExpandedStringValue(constHive, strKey, strValueName, strValue)
-	private_oReg.GetExpandedStringValue constHive, strKey, strValueName, strValue
-End Sub
-
-Function SetMultiStringValue(constHive, strSubKey, strValueName, arrValue)
-	SetMultiStringValue = private_oReg.SetMultiStringValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetMultiStringValue(constHive, strKey, strValueName, arrStrValue)
-	private_oReg.GetMultiStringValue constHive, strKey, strValueName, arrStrValue
-End Sub 
-
-Function SetDWORDValue(constHive, strSubKey, strValueName, arrValue)
-	SetDWORDValue = private_oReg.SetDWORDValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetDWORDValue(constHive, strKey, strValueName, intDWordValue)
-	private_oReg.GetDWORDValue constHive, strKey, strValueName, intDWordValue
-End Sub
-
-Function SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue)
-	SetQWORDValue = private_oReg.SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue)
-End Function
-
-Sub GetQWORDValue(constHive, strKey, strValueName, intQWordValue)
-	private_oReg.GetQWORDValue constHive, strKey, strValueName, intQWordValue
-End Sub
-
-Function SetBinaryValue(constHive, strSubKey, strValueName, arrValue)
-	SetBinaryValue = private_oReg.SetBinaryValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetBinaryValue(constHive, strKey, strValueName, arrBinaryValue)
-	private_oReg.GetBinaryValue constHive, strKey, strValueName, arrBinaryValue
-End Sub
-
-Function EnumKey(constHive, strSubKey, arrKeyNames)
-	EnumKey = private_oReg.EnumKey(constHive, strSubKey, arrKeyNames)
-End Function
-
-Function EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes)
-	EnumValues = private_oReg.EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes)
-End Function
-
-Function CreateKey(constHive, strSubKey)
-	CreateKey = private_oReg.CreateKey(constHive, strSubKey)
-End Function
-
-Function DeleteKey(constHive, strSubKey)
-	DeleteKey = private_oReg.DeleteKey(constHive, strSubKey)
-End Function
-
-Function DeleteValue(constHive, strSubKey, strValue)
-	DeleteValue = private_oReg.DeleteValue(constHive, strSubKey, strValue)
-End Function

+ 0 - 358
bin/ia32/vbs/ArchitectureSpecificRegistry.vbs

@@ -1,358 +0,0 @@
-' Notes: wanted to implement this using a class but:
-' 1. No matter what I did I could not assign the result of GetObject to a private member
-' 2. It looks as if all methods were treated as subs from the outside world which is not good since 
-' some of these need to return a value
-
-' should be removed when migration is complete
-Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv")		
-
-Set private_oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
-private_oCtx.Add "__ProviderArchitecture", CInt(OSArchitecture)
-
-Set private_oLocator = CreateObject("Wbemscripting.SWbemLocator")
-Set private_oServices = private_oLocator.ConnectServer(".", "root\default","","",,,,private_oCtx)
-Set private_oRegSpecific = private_oServices.Get("StdRegProv") 
-
-Function CheckAccess(hDefKey,sSubKeyName,uRequired, bGranted )	
-	Set Inparams = private_oRegSpecific.Methods_("CheckAccess").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.uRequired = uRequired
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("CheckAccess", Inparams,,private_oCtx)
-	
-	bGranted = Outparams.bGranted
-	
-
-	CheckAccess = 0
-	
-End Function
-
-Function CreateKey(hDefKey,sSubKeyName)	
-	Set Inparams = private_oRegSpecific.Methods_("CreateKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("CreateKey", Inparams,,private_oCtx)
-	
-
-	CreateKey = 0
-	
-End Function
-
-Function DeleteKey(hDefKey,sSubKeyName)	
-	Set Inparams = private_oRegSpecific.Methods_("DeleteKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("DeleteKey", Inparams,,private_oCtx)
-	
-
-	DeleteKey = 0
-	
-End Function
-
-Function DeleteValue(hDefKey,sSubKeyName,sValueName)	
-	Set Inparams = private_oRegSpecific.Methods_("DeleteValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("DeleteValue", Inparams,,private_oCtx)
-	
-
-	DeleteValue = 0
-	
-End Function
-
-Function EnumKey(hDefKey,sSubKeyName, sNames )	
-	Set Inparams = private_oRegSpecific.Methods_("EnumKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("EnumKey", Inparams,,private_oCtx)
-	
-	sNames = Outparams.sNames
-	
-
-	EnumKey = 0
-	
-End Function
-
-Function EnumValues(hDefKey,sSubKeyName, sNames,Types )	
-	Set Inparams = private_oRegSpecific.Methods_("EnumValues").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("EnumValues", Inparams,,private_oCtx)
-	
-	sNames = Outparams.sNames
-	
-	Types = Outparams.Types
-	
-
-	EnumValues = 0
-	
-End Function
-
-Function GetBinaryValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetBinaryValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetBinaryValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetBinaryValue = 0
-	
-End Function
-
-Function GetDWORDValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetDWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetDWORDValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetDWORDValue = 0
-	
-End Function
-
-Function GetExpandedStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetExpandedStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetExpandedStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetExpandedStringValue = 0
-	
-End Function
-
-Function GetMultiStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetMultiStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetMultiStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetMultiStringValue = 0
-	
-End Function
-
-Function GetQWORDValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetQWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetQWORDValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetQWORDValue = 0
-	
-End Function
-
-Function GetSecurityDescriptor(hDefKey,sSubKeyName, Descriptor )	
-	Set Inparams = private_oRegSpecific.Methods_("GetSecurityDescriptor").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetSecurityDescriptor", Inparams,,private_oCtx)
-	
-	Descriptor = Outparams.Descriptor
-	
-
-	GetSecurityDescriptor = 0
-	
-End Function
-
-Function GetStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetStringValue = 0
-	
-End Function
-
-Function SetBinaryValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetBinaryValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetBinaryValue", Inparams,,private_oCtx)
-	
-
-	SetBinaryValue = 0
-	
-End Function
-
-Function SetDWORDValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetDWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetDWORDValue", Inparams,,private_oCtx)
-	
-
-	SetDWORDValue = 0
-	
-End Function
-
-Function SetExpandedStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetExpandedStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetExpandedStringValue", Inparams,,private_oCtx)
-	
-
-	SetExpandedStringValue = 0
-	
-End Function
-
-Function SetMultiStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetMultiStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetMultiStringValue", Inparams,,private_oCtx)
-	
-
-	SetMultiStringValue = 0
-	
-End Function
-
-Function SetQWORDValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetQWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetQWORDValue", Inparams,,private_oCtx)
-	
-
-	SetQWORDValue = 0
-	
-End Function
-
-Function SetSecurityDescriptor(hDefKey,sSubKeyName,Descriptor)	
-	Set Inparams = private_oRegSpecific.Methods_("SetSecurityDescriptor").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.Descriptor = Descriptor
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetSecurityDescriptor", Inparams,,private_oCtx)
-	
-
-	SetSecurityDescriptor = 0
-	
-End Function
-
-Function SetStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetStringValue", Inparams,,private_oCtx)
-	
-
-	SetStringValue = 0
-	
-End Function

+ 0 - 7
bin/ia32/vbs/JsonSafeTest.wsf

@@ -1,7 +0,0 @@
-<job id="JsonSafeStreamTest">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript">		
-		str = """" & vbcrlf & "测试\"
-		Write("{ ""a"": """ & JsonSafe(str) & """}" & vbcrlf)
-	</script>
-</job>

+ 0 - 32
bin/ia32/vbs/regCreateKey.wsf

@@ -1,32 +0,0 @@
-<job id="createKeyStream">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regCreateKey.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-			strLine = stdin.ReadLine()			
-			strLine = unescape(trim(strLine))
-
-			If IsNull(strLine) or strLine = "" Then
-				WScript.Quit 25127
-			End If
-			
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122
-			End If
-
-			Result = CreateKey(constHive, strSubKey)
-
-			If Not Result = 0 Then				
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 29
bin/ia32/vbs/regDeleteKey.wsf

@@ -1,29 +0,0 @@
-<job id="deleteKey">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regDeleteKey.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-			
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-		
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122   
-			End If
-
-			Result = DeleteKey(constHive, strSubKey)
-
-			If Not Result = 0 Then				
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 29
bin/ia32/vbs/regDeleteValue.wsf

@@ -1,29 +0,0 @@
-<job id="deleteValue">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regDeleteValue.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-
-			ParseHiveAndSubKeyAndValue strLine, constHive, strSubKey, strValue
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122
-			End If
-
-			Result = DeleteValue(constHive, strSubKey, strValue)
-
-			If Not Result = 0 Then
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 47
bin/ia32/vbs/regList.wsf

@@ -1,47 +0,0 @@
-' 
-'	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 "{"
-		On Error Resume Next
-		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>

+ 0 - 46
bin/ia32/vbs/regListStream.wsf

@@ -1,46 +0,0 @@
-' 
-'	Lists the sub keys and values of a given registry key, this script is slightly different
-'	than regList because it reads stdin for the keys to list
-'
-'	cscript regList.wsg HKLM\Software
-'
-'	Will Yield:
-'
-'	{
-'		"hklm\software": { 
-'			"keys": [ .. array of sub keys .. ], 
-'			"values": { 
-'				"moo": { 
-'					"type": "REG_SZ", 
-'					"value": "bar"
-'				}
-'			}
-'		}
-'	}
-<job id="listStream">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">		
-		CheckZeroArgs("usage: cscript regList.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-		
-		Do While Not stdin.AtEndOfLine
-
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-		
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122       
-			End If
-
-			Write "{ ""key"" : """ & JsonSafe(strLine) & """, ""data"": "
-			ListChildrenAsJson constHive, strSubKey
-			Write "}" & vbcrlf
-		Loop
-
-	</script>
-</job>

+ 0 - 56
bin/ia32/vbs/regPutValue.wsf

@@ -1,56 +0,0 @@
-<job id="putValue">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-		usage = "usage: cscript regPutValue.wsf architecture" & vbNewLine _
-					& "types: REG_SZ, REG_EXPAND_SZ, REG_BINARY, REG_DWORD, REG_MULTI_SZ, REG_QWORD"
-	
-		CheckZeroArgs(usage)
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-		
-		ReadCount = 0
-		Dim lineArgs(3)
-
-		Do While Not stdin.AtEndOfLine
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-			
-			If IsNull(strLine) or strLine = "" Then
-				WScript.Quit 25127
-			End If
-
-			lineArgs(ReadCount) = strLine
-			
-			ReadCount = ReadCount + 1
-
-			If ReadCount = 4 Then
-
-				ParseHiveAndSubKey lineArgs(0), constHive, strSubKey
-				
-				if IsNull(constHive) Then
-					WriteLineErr "unsupported hive " & lineArgs(0)
-					WScript.Quit 25122
-				End If
-
-				strValueName = lineArgs(1)
-				strValue = lineArgs(2)
-				strType = lineArgs(3)
-				
-				Result = PutValue(constHive, strSubKey, strValueName, strValue, strType)
-
-				If Not Result = 0 Then
-					WriteLineErr "error while putting value: " & result
-					WScript.Quit Result
-				End If
-
-				ReadCount = 0
-				Erase lineArgs				
-			End If
-		Loop
-
-		If ReadCount <> 0 Then
-			WScript.Quit 25123
-		End If
-	</script>
-</job>

+ 0 - 358
bin/ia32/vbs/regUtil.vbs

@@ -1,358 +0,0 @@
-' TODO: consider incorporating a json writer of some sort instead of adhoc solution like the following
-' e.g: http://demon.tw/my-work/vbs-json.html
-
-const HKEY_CLASSES_ROOT = &H80000000
-const HKEY_CURRENT_USER = &H80000001
-const HKEY_LOCAL_MACHINE = &H80000002
-const HKEY_USERS = &H80000003
-const HKEY_CURRENT_CONFIG = &H80000005
-
-Sub LoadRegistryImplementationByOSArchitecture()
-	If IsNull(OSArchitecture) Then
-		WriteLineErr "missing OSArchitecture global. did not call util.DetermineOSArchitecture? or Forgot to load util.vbs?"
-		WScript.Quit 25125		
-	End If
-
-	If OSArchitecture = "A" Then
-		Include "ArchitectureAgnosticRegistry.vbs"
-	Else
-		Include "ArchitectureSpecificRegistry.vbs"
-	End If
-End Sub 
-
-Function PutValue(constHive, strSubKey, strValueName, strValue, strType)
-	Select Case UCase(strType)
-		
-		Case "REG_SZ"
-			PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_EXPAND_SZ"
-			PutValue = SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_BINARY"
-			PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue))
-
-		Case "REG_NONE"
-			PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue))
-
-		' TODO: need to check that indeed int is the right type here
-		Case "REG_DWORD"
-			PutValue = SetDWORDValue(constHive, strSubKey, strValueName, CDbl(strValue))
-
-		Case "REG_MULTI_SZ"
-			PutValue = SetMultiStringValue(constHive, strSubKey, strValueName, Split(strValue, ","))
-
-		Case "REG_QWORD"
-			PutValue = SetQWORDValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_DEFAULT"
-			PutValue = SetStringValue(constHive, strSubKey, "", strValue)
-
-		Case Else
-			PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue)
-
-	End Select
-End Function
-
-' render the child of a sub path strSubKey in hive constHive
-' as json.
-Sub ListChildrenAsJson(constHive, strSubKey)
-	' start outputting json to stdout
-	Write "{"
-
-	Dim e1: e1 = EnumKey (constHive, strSubKey, arrKeyNames)
-	If e1 <> 0 Then
-		Write """exists"": false,"
-		Dim arrValueNames: arrValueNames = null
-	Else
-		Write """exists"": true,"
-
-		Dim e2: e2 = EnumValues (constHive, strSubKey, arrValueNames, arrValueTypes)
-		If e2 <> 0 Then
-			WScript.Quit e2
-		End If
-	End If
-
-	Write """keys"": ["
-	If Not IsNull(arrKeyNames) Then
-		For x = 0 To UBound(arrKeyNames)
-			If (x > 0) Then
-				Write ","
-			End If
-	
-			Write """" & JsonSafe(arrKeyNames(x)) & """"
-		Next
-	End If
-	Write "],"
-	' TODO: some duplicity of code between the two paths of this condition, this needs to be address at some point
-	Write """values"":{"
-	If Not IsNull(arrValueNames) Then
-		For y = 0 To UBound(arrValueNames)
-			If y > 0 Then
-				Write ","
-			End If
-
-			strValueName = arrValueNames(y)
-			intValueType = arrValueTypes(y)
-			
-			' assign the value to varValue
-			GetValueByType constHive, strSubKey, strValueName, intValueType, varValue
-			
-			WriteValue strValueName, intValueType, varValue
-		Next
-	Else
-		' fix for keys with only default values in them
-		' see http://stackoverflow.com/questions/8840343/how-to-read-the-default-value-from-registry-in-vbscript
-		GetStringValue constHive, strSubKey, "", strDefaultValue
-
-		If IsNull(strDefaultValue) = false and strDefaultValue <> "" Then
-			' write the default value with REG_SZ
-			WriteValue "", 1, strDefaultValue
-		End If
-	End If
-	Write "}}"	
-End Sub
-
-Sub WriteValue (strValueName, intValueType, varValue)
-	Write """"  
-	Write JsonSafe(strValueName)
-	Write """:{"
-	Write """type"": """
-	Write RenderType(intValueType)
-	Write ""","
-	Write """value"":"
-	Write RenderValueByType(intValueType, varValue)
-	Write "}"
-End Sub
-
-' give a raw HKLM\something\somewhere
-' output the hive constant and the subkey, in this case:
-' HKEY_LOCAL_MACHINE will be assigned to outConstHive
-' and something\somewhere will be assigned to outStrSubKey
-Sub ParseHiveAndSubKey(strRawKey, outConstHive, outStrSubKey)	
-	' split into two parts to deduce the hive and the sub key
-	arrSplitted = Split(strRawKey, "\", 2, 1)
-	
-	If UBound(arrSplitted) > 0 Then
-		strHive = arrSplitted(0)	
-		outStrSubKey = arrSplitted(1)
-	Else
-		strHive = strRawKey
-		outStrSubKey = ""
-	End If
-
-	outConstHive = StringToHiveConst(UCase(strHive))
-End Sub
-
-Function ArrayRemoveAt(arr, pos)
-  Dim i
-  If IsArray(arr) Then
-    If pos >= 0 And pos <= UBound(arr) Then
-      For i = pos To UBound(arr) - 1
-        arr(i) = arr(i + 1)
-      Next
-      ReDim Preserve arr(UBound(arr) - 1)
-    End If
-  End If
-End Function
-
-Sub ParseHiveAndSubKeyAndValue(strRawKey, outConstHive, outStrSubKey, outStrValue)
-	' split into two parts to deduce the hive and the sub key
-	arrSplitted = Split(strRawKey, "\", -1, 1)
-
-	If UBound(arrSplitted) > 0 Then
-		strHive = arrSplitted(0)
-        outStrValue = arrSplitted(UBound(arrSplitted))
-        test = ArrayRemoveAt(arrSplitted, UBound(arrSplitted))
-        test = ArrayRemoveAt(arrSplitted, 0)
-        outStrSubKey = Join(arrSplitted, "\")
-	Else
-		strHive = strRawKey
-		outStrSubKey = ""
-	End If
-
-	outConstHive = StringToHiveConst(UCase(strHive))
-End Sub
-
-Function StringToHiveConst(strHive)
-	
-	Select Case strHive
-		Case "HKCR"
-			StringToHiveConst = HKEY_CLASSES_ROOT
-		Case "HKCU"
-			StringToHiveConst = HKEY_CURRENT_USER
-		Case "HKLM"
-			StringToHiveConst = HKEY_LOCAL_MACHINE
-		Case "HKU"
-			StringToHiveConst = HKEY_USERS
-		Case "HKCC"
-			StringToHiveConst = HKEY_CURRENT_CONFIG
-		Case Else
-			StringToHiveConst = Null	
-	End Select	
-
-End Function
-
-' TODO: this entire "by type" should be transformed into OOP style
-' where each type will have a class with render(), getValue() etc...
-
-' convert a value type number into a string label
-Function RenderType(intType)
-	RenderType = "REG_UNKNOWN"
-
-	Select Case intType
-		Case 0
-			RenderType = "REG_NONE"
-		Case 1
-			RenderType = "REG_SZ"
-		Case 2
-			RenderType = "REG_EXPAND_SZ"
-		Case 3
-			RenderType = "REG_BINARY"
-		Case 4
-			RenderType = "REG_DWORD"
-		Case 7
-			RenderType = "REG_MULTI_SZ"
-		Case 11	
-			RenderType = "REG_QWORD"
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)
-
-	End Select
-
-End Function
-
-' render by value type:
-' string will return as a string with double quotes, e.g "value"
-' multi string values which return as an array ot strings "["1", "2"]" (double quotes included ofc)
-' numeric values like DWORD and QWORD just return as the number e.g. 1
-' byte arrays such as reg_binary return as an array of ints, e.g [1,2,3]
-Function RenderValueByType(intType, varValue)
-
-	Select Case intType
-		' REG_NONE
-		Case 0
-			RenderValueByType = "0"
-
-		' REG_SZ
-		Case 1
-			RenderValueByType = """" & JsonSafe(varValue) & """"
-
-		' REG_EXPAND_SZ
-		Case 2
-			RenderValueByType = """" & JsonSafe(varValue) & """"
-
-		' REG_BINARY
-		Case 3
-			RenderValueByType = RenderByteArray(varValue)
-
-		' REG_DWORD
-		Case 4
-			RenderValueByType= varValue
-
-		' REG_MULYI_SZ'
-		Case 7
-
-			RenderValueByType = RenderStringArray(varValue)
-		' REG_QWORD
-		Case 11
-			RenderValueByType = varValue
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)
-	End Select
-
-End Function
-
-' get the value of a registry based on its value type and assign it to out parameter outVarValue
-Sub GetValueByType(constHive, strKey, strValueName, intType, outVarValue)
-
-	Select Case intType
-		' REG_NONE
-		Case 0
-			GetStringValue constHive, strKey, strValueName, "0"
-			Exit Sub
-
-		' REG_SZ
-		Case 1
-			GetStringValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-
-		' REG_EXPAND_SZ
-		Case 2
-			GetExpandedStringValue constHive, strKey, strValueName, outVarValue			
-			Exit Sub
-			
-		' REG_BINARY
-		Case 3
-			GetBinaryValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-			
-		' REG_DWORD
-		Case 4
-			GetDWORDValue constHive, strKey, strValueName, outVarValue
-
-			' #21 - VBS does not support UInt32. This is the workaround
-			If outVarValue < 0 Then outVarValue = 4294967296 + outVarValue
-
-			Exit Sub
-			
-		' REG_MULYI_SZ'
-		Case 7
-			GetMultiStringValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-			
-		' REG_QWORD
-		Case 11	
-			GetQWORDValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-		
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)	
-	End Select
-
-End Sub
-
-' render a byte array as a json array of numbers
-Function RenderByteArray(arr)
-	RenderByteArray = "[]"
-
-	If Not IsNull(arr) Then		
-		RenderByteArray = "[" & Join(arr, ",") & "]"
-	End If
-End Function
-
-' render a string array as json string array
-Function RenderStringArray(arr)	
-	Result = "["
-	If Not IsNull(arr) Then
-		For t = 0 To UBound(arr)
-			If (t > 0) Then
-				Result = Result &  ","
-			End If
-
-			Result = Result & """" & JsonSafe(arr(t)) & """"
-		Next
-	End If
-	Result = Result & "]"
-
-	RenderStringArray = Result
-End Function
-
-Function ToBinaryValue(strValue)
-
-	arrValue = Split(strValue, ",")
-	
-	If IsNull(arrValue) Then		
-		ToBinaryValue = Array()
-		Exit Function
-	End If
-
-	For i = 0 To UBound(arrValue)
-		arrValue(i) = CInt(arrValue(i))
-	Next
-
-	ToBinaryValue = arrValue
-End Function

+ 0 - 162
bin/ia32/vbs/util.vbs

@@ -1,162 +0,0 @@
-Set stdout = WScript.StdOut
-Set stderr = WScript.StdErr
-Set stdin = WScript.StdIn
-Set args = WScript.Arguments
-Set fs = CreateObject("scripting.filesystemobject") 
-Dim OSArchitecture
-
-Sub WriteErr(message)
-	stderr.Write message
-End Sub
-
-Sub WriteLineErr(message)
-	stderr.WriteLine message
-End Sub
-
-Sub Write(message)
-	stdout.Write message
-End Sub
-
-Sub WriteLine(message)
-	stdout.WriteLine message
-End Sub
-
-Function IndexOf(varNeedle, arrHaystack)
-	IndexOf = -1
-	
-	If Not IsArray(arrHaystack)	 Then
-		Exit Function
-	End If
-
-	For xyz = 0 To UBound(arrHaystack)
-		If arrHaystack(xyz) = varNeedle Then
-			IndexOf = xyz
-			Exit Function
-		End If
-	Next
-End Function
-
-Sub CheckZeroArgs(message)
-	' bail if args are missing
-	If args.Count = 0 Then
-		WriteLineErr message
-		WScript.Quit 25121
-	End If
-End Sub
-
-Dim ALLOWED_OS_ARCHITECTURE_VALUES: ALLOWED_OS_ARCHITECTURE_VALUES = Array("S", "A", "32", "64")
-
-'
-'	determine the architecture of the operating system, that will be used. there are 4 possibilities:
-'	A - means agnostic
-'	S - means that we want to use a specific architecture, but auto detect Item
-'	32 - explicitly use 32 bit architecture
-'	64 - explicitly use 64 bit architecture
-'
-Sub DetermineOSArchitecture()
-	strArchitecture = args(0)
-
-	If IsNull(strArchitecture) Then
-		WriteLineErr "missing architecture argument"
-		WScript.Quit 25124
-	End If
-
-	strArchitecture = UCase(strArchitecture)
-
-	If IndexOf(strArchitecture, ALLOWED_OS_ARCHITECTURE_VALUES) = -1 Then
-		WriteLineErr "invalid architecture argument"
-		WScript.Quit 25124
-	End If
-
-	If (strArchitecture = "S") Then
-		OSArchitecture = GetOSArchitecture()
-		If OSArchitecture = -1 Then
-			WriteLineErr "invalid os architecture detected " & OSArchitecture
-			WScript.Quit 25126
-		End If
-	Else
-		OSArchitecture = strArchitecture
-	End If
-
-End Sub
-
-Sub Include(sPath)
-	' TODO this is fragile, but should work for "modules" nested relatively to script root
-	include_ScriptPath = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName) - 2)	
-	sPath = include_ScriptPath & "\" & sPath
-	
-	include_code = fs.OpenTextFile(sPath).ReadAll 	
-	ExecuteGlobal include_code
-End Sub
-
-Function GetOSArchitecture()
-
-	Dim ObjWMI, ColSettings, ObjProcessor 
-	Dim StrComputer, ObjNetwork 
-	
-	Set ObjWMI = GetObject("winmgmts:\Root\CIMV2") 
-	Set ColSettings = ObjWMI.ExecQuery ("SELECT DataWidth, AddressWidth, Architecture FROM Win32_Processor") 
-
-	' TODO: I make two assumptions here: 
-	' 1. Eveyone will have CPU0 device
-	' 2. There is only one cpu defined in the wmi database (and if not, then they are all of the same architecture)
-	Set ObjProcessor = ColSettings.Item("Win32_Processor.DeviceID=""CPU0""")
-
-	If ObjProcessor.Architecture = 0 AND ObjProcessor.AddressWidth = 32 Then 
-		GetOSArchitecture = 32
-	ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 32 Then 
-		GetOSArchitecture = 32
-	ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 
-		GetOSArchitecture = 64
-	Else		
-		GetOSArchitecture = -1
-	End If 
-	
-End Function
-
-Function JsonSafe(outStrText)
-	If outStrText = "" Then
-		JsonSafe = ""
-		Exit Function 
-	End If
-		
-	outStrText = Replace(outStrText, "\", "\\")
-	outStrText = Replace(outStrText, vbcrlf, "\\r\\n")
-	outStrText = Replace(outStrText, vblf, "\\n")
-	outStrText = Replace(outStrText, vbcr, "\\r")
-	outStrText = Replace(outStrText, """", "\""")	
-	outStrText = JsonU(outStrText)
-	JsonSafe = outStrText
-End Function
-
-'TODO: need to change this function's name to something more appropriate
-Function JsonU(astr)
-	
-	If isNull(astr) Then
-		JsonU = ""
-		Exit Function
-	End If
-
-	Dim c 
-	Dim utftext: utftext = ""
-	
-	For n = 1 To Len(astr)
-		c = CLng(AscW(Mid(astr, n, 1)))
-
-		If c < 0 Then
-			c = &H10000 + c
-		End If
-
-		If c < &H80 Then
-			utftext = utftext & Mid(astr, n, 1)
-		ElseIf c < &H100 Then
-			utftext = utftext & "\u00" & Hex(c)
-		ElseIf c < &H1000 Then
-			utftext = utftext & "\u0" & Hex(c)
-		Else
-			utftext = utftext & "\u" & Hex(c)
-		End If
-	Next
-
-	JsonU = utftext
-End Function

+ 0 - 75
bin/x64/vbs/ArchitectureAgnosticRegistry.vbs

@@ -1,75 +0,0 @@
-' Notes: wanted to implement this using a class but:
-' 1. No matter what I did I could not assign the result of GetObject to a private member
-' 2. It looks as if all methods were treated as subs from the outside world which is not good since 
-' some of these need to return a value
-'
-
-Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv")		
-
-Function SetStringValue(constHive, strSubKey, strValueName, strValue)	
-	SetStringValue  = private_oReg.SetStringValue(constHive, strSubKey, strValueName, strValue)	
-End Function
-
-Sub GetStringValue(constHive, strKey, strValueName, strValue)
-	private_oReg.GetStringValue constHive, strKey, strValueName, strValue
-End Sub
-
-Function SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-	SetExpandedStringValue = private_oReg.SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-End Function
-
-Sub GetExpandedStringValue(constHive, strKey, strValueName, strValue)
-	private_oReg.GetExpandedStringValue constHive, strKey, strValueName, strValue
-End Sub
-
-Function SetMultiStringValue(constHive, strSubKey, strValueName, arrValue)
-	SetMultiStringValue = private_oReg.SetMultiStringValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetMultiStringValue(constHive, strKey, strValueName, arrStrValue)
-	private_oReg.GetMultiStringValue constHive, strKey, strValueName, arrStrValue
-End Sub 
-
-Function SetDWORDValue(constHive, strSubKey, strValueName, arrValue)
-	SetDWORDValue = private_oReg.SetDWORDValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetDWORDValue(constHive, strKey, strValueName, intDWordValue)
-	private_oReg.GetDWORDValue constHive, strKey, strValueName, intDWordValue
-End Sub
-
-Function SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue)
-	SetQWORDValue = private_oReg.SetQWORDValue(constHive, strSubKey, strValueName, strQWordValue)
-End Function
-
-Sub GetQWORDValue(constHive, strKey, strValueName, intQWordValue)
-	private_oReg.GetQWORDValue constHive, strKey, strValueName, intQWordValue
-End Sub
-
-Function SetBinaryValue(constHive, strSubKey, strValueName, arrValue)
-	SetBinaryValue = private_oReg.SetBinaryValue(constHive, strSubKey, strValueName, arrValue)
-End Function
-
-Sub GetBinaryValue(constHive, strKey, strValueName, arrBinaryValue)
-	private_oReg.GetBinaryValue constHive, strKey, strValueName, arrBinaryValue
-End Sub
-
-Function EnumKey(constHive, strSubKey, arrKeyNames)
-	EnumKey = private_oReg.EnumKey(constHive, strSubKey, arrKeyNames)
-End Function
-
-Function EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes)
-	EnumValues = private_oReg.EnumValues(constHive, strSubKey, arrValueNames, arrValueTypes)
-End Function
-
-Function CreateKey(constHive, strSubKey)
-	CreateKey = private_oReg.CreateKey(constHive, strSubKey)
-End Function
-
-Function DeleteKey(constHive, strSubKey)
-	DeleteKey = private_oReg.DeleteKey(constHive, strSubKey)
-End Function
-
-Function DeleteValue(constHive, strSubKey, strValue)
-	DeleteValue = private_oReg.DeleteValue(constHive, strSubKey, strValue)
-End Function

+ 0 - 358
bin/x64/vbs/ArchitectureSpecificRegistry.vbs

@@ -1,358 +0,0 @@
-' Notes: wanted to implement this using a class but:
-' 1. No matter what I did I could not assign the result of GetObject to a private member
-' 2. It looks as if all methods were treated as subs from the outside world which is not good since 
-' some of these need to return a value
-
-' should be removed when migration is complete
-Set private_oReg = GetObject("winmgmts:\root\default:StdRegProv")		
-
-Set private_oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
-private_oCtx.Add "__ProviderArchitecture", CInt(OSArchitecture)
-
-Set private_oLocator = CreateObject("Wbemscripting.SWbemLocator")
-Set private_oServices = private_oLocator.ConnectServer(".", "root\default","","",,,,private_oCtx)
-Set private_oRegSpecific = private_oServices.Get("StdRegProv") 
-
-Function CheckAccess(hDefKey,sSubKeyName,uRequired, bGranted )	
-	Set Inparams = private_oRegSpecific.Methods_("CheckAccess").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.uRequired = uRequired
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("CheckAccess", Inparams,,private_oCtx)
-	
-	bGranted = Outparams.bGranted
-	
-
-	CheckAccess = 0
-	
-End Function
-
-Function CreateKey(hDefKey,sSubKeyName)	
-	Set Inparams = private_oRegSpecific.Methods_("CreateKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("CreateKey", Inparams,,private_oCtx)
-	
-
-	CreateKey = 0
-	
-End Function
-
-Function DeleteKey(hDefKey,sSubKeyName)	
-	Set Inparams = private_oRegSpecific.Methods_("DeleteKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("DeleteKey", Inparams,,private_oCtx)
-	
-
-	DeleteKey = 0
-	
-End Function
-
-Function DeleteValue(hDefKey,sSubKeyName,sValueName)	
-	Set Inparams = private_oRegSpecific.Methods_("DeleteValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("DeleteValue", Inparams,,private_oCtx)
-	
-
-	DeleteValue = 0
-	
-End Function
-
-Function EnumKey(hDefKey,sSubKeyName, sNames )	
-	Set Inparams = private_oRegSpecific.Methods_("EnumKey").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("EnumKey", Inparams,,private_oCtx)
-	
-	sNames = Outparams.sNames
-	
-
-	EnumKey = 0
-	
-End Function
-
-Function EnumValues(hDefKey,sSubKeyName, sNames,Types )	
-	Set Inparams = private_oRegSpecific.Methods_("EnumValues").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("EnumValues", Inparams,,private_oCtx)
-	
-	sNames = Outparams.sNames
-	
-	Types = Outparams.Types
-	
-
-	EnumValues = 0
-	
-End Function
-
-Function GetBinaryValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetBinaryValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetBinaryValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetBinaryValue = 0
-	
-End Function
-
-Function GetDWORDValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetDWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetDWORDValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetDWORDValue = 0
-	
-End Function
-
-Function GetExpandedStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetExpandedStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetExpandedStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetExpandedStringValue = 0
-	
-End Function
-
-Function GetMultiStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetMultiStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetMultiStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetMultiStringValue = 0
-	
-End Function
-
-Function GetQWORDValue(hDefKey,sSubKeyName,sValueName, uValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetQWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetQWORDValue", Inparams,,private_oCtx)
-	
-	uValue = Outparams.uValue
-	
-
-	GetQWORDValue = 0
-	
-End Function
-
-Function GetSecurityDescriptor(hDefKey,sSubKeyName, Descriptor )	
-	Set Inparams = private_oRegSpecific.Methods_("GetSecurityDescriptor").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetSecurityDescriptor", Inparams,,private_oCtx)
-	
-	Descriptor = Outparams.Descriptor
-	
-
-	GetSecurityDescriptor = 0
-	
-End Function
-
-Function GetStringValue(hDefKey,sSubKeyName,sValueName, sValue )	
-	Set Inparams = private_oRegSpecific.Methods_("GetStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("GetStringValue", Inparams,,private_oCtx)
-	
-	sValue = Outparams.sValue
-	
-
-	GetStringValue = 0
-	
-End Function
-
-Function SetBinaryValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetBinaryValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetBinaryValue", Inparams,,private_oCtx)
-	
-
-	SetBinaryValue = 0
-	
-End Function
-
-Function SetDWORDValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetDWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetDWORDValue", Inparams,,private_oCtx)
-	
-
-	SetDWORDValue = 0
-	
-End Function
-
-Function SetExpandedStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetExpandedStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetExpandedStringValue", Inparams,,private_oCtx)
-	
-
-	SetExpandedStringValue = 0
-	
-End Function
-
-Function SetMultiStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetMultiStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetMultiStringValue", Inparams,,private_oCtx)
-	
-
-	SetMultiStringValue = 0
-	
-End Function
-
-Function SetQWORDValue(hDefKey,sSubKeyName,sValueName,uValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetQWORDValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.uValue = uValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetQWORDValue", Inparams,,private_oCtx)
-	
-
-	SetQWORDValue = 0
-	
-End Function
-
-Function SetSecurityDescriptor(hDefKey,sSubKeyName,Descriptor)	
-	Set Inparams = private_oRegSpecific.Methods_("SetSecurityDescriptor").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.Descriptor = Descriptor
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetSecurityDescriptor", Inparams,,private_oCtx)
-	
-
-	SetSecurityDescriptor = 0
-	
-End Function
-
-Function SetStringValue(hDefKey,sSubKeyName,sValueName,sValue)	
-	Set Inparams = private_oRegSpecific.Methods_("SetStringValue").Inparameters
-	
-	Inparams.hDefKey = hDefKey
-	
-	Inparams.sSubKeyName = sSubKeyName
-	
-	Inparams.sValueName = sValueName
-	
-	Inparams.sValue = sValue
-		
-	set Outparams = private_oRegSpecific.ExecMethod_("SetStringValue", Inparams,,private_oCtx)
-	
-
-	SetStringValue = 0
-	
-End Function

+ 0 - 7
bin/x64/vbs/JsonSafeTest.wsf

@@ -1,7 +0,0 @@
-<job id="JsonSafeStreamTest">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript">		
-		str = """" & vbcrlf & "测试\"
-		Write("{ ""a"": """ & JsonSafe(str) & """}" & vbcrlf)
-	</script>
-</job>

+ 0 - 32
bin/x64/vbs/regCreateKey.wsf

@@ -1,32 +0,0 @@
-<job id="createKeyStream">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regCreateKey.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-			strLine = stdin.ReadLine()			
-			strLine = unescape(trim(strLine))
-
-			If IsNull(strLine) or strLine = "" Then
-				WScript.Quit 25127
-			End If
-			
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122
-			End If
-
-			Result = CreateKey(constHive, strSubKey)
-
-			If Not Result = 0 Then				
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 29
bin/x64/vbs/regDeleteKey.wsf

@@ -1,29 +0,0 @@
-<job id="deleteKey">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regDeleteKey.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-			
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-		
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122   
-			End If
-
-			Result = DeleteKey(constHive, strSubKey)
-
-			If Not Result = 0 Then				
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 29
bin/x64/vbs/regDeleteValue.wsf

@@ -1,29 +0,0 @@
-<job id="deleteValue">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-
-		CheckZeroArgs("usage: cscript regDeleteValue.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-
-		Do While Not stdin.AtEndOfLine
-
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-
-			ParseHiveAndSubKeyAndValue strLine, constHive, strSubKey, strValue
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122
-			End If
-
-			Result = DeleteValue(constHive, strSubKey, strValue)
-
-			If Not Result = 0 Then
-				WScript.Quit Result
-			End If
-		Loop
-	</script>
-</job>

+ 0 - 47
bin/x64/vbs/regList.wsf

@@ -1,47 +0,0 @@
-' 
-'	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 "{"
-		On Error Resume Next
-		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>

+ 0 - 46
bin/x64/vbs/regListStream.wsf

@@ -1,46 +0,0 @@
-' 
-'	Lists the sub keys and values of a given registry key, this script is slightly different
-'	than regList because it reads stdin for the keys to list
-'
-'	cscript regList.wsg HKLM\Software
-'
-'	Will Yield:
-'
-'	{
-'		"hklm\software": { 
-'			"keys": [ .. array of sub keys .. ], 
-'			"values": { 
-'				"moo": { 
-'					"type": "REG_SZ", 
-'					"value": "bar"
-'				}
-'			}
-'		}
-'	}
-<job id="listStream">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">		
-		CheckZeroArgs("usage: cscript regList.wsf architecture")
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-		
-		Do While Not stdin.AtEndOfLine
-
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-		
-			ParseHiveAndSubKey strLine, constHive, strSubKey
-
-			if IsNull(constHive) Then
-				WriteLineErr "unsupported hive " & strLine
-				WScript.Quit 25122       
-			End If
-
-			Write "{ ""key"" : """ & JsonSafe(strLine) & """, ""data"": "
-			ListChildrenAsJson constHive, strSubKey
-			Write "}" & vbcrlf
-		Loop
-
-	</script>
-</job>

+ 0 - 56
bin/x64/vbs/regPutValue.wsf

@@ -1,56 +0,0 @@
-<job id="putValue">
-	<script language="VBScript" src="util.vbs" />
-	<script language="VBScript" src="regUtil.vbs" />
-	<script language="VBScript">
-		usage = "usage: cscript regPutValue.wsf architecture" & vbNewLine _
-					& "types: REG_SZ, REG_EXPAND_SZ, REG_BINARY, REG_DWORD, REG_MULTI_SZ, REG_QWORD"
-	
-		CheckZeroArgs(usage)
-		DetermineOSArchitecture()
-		LoadRegistryImplementationByOSArchitecture()
-		
-		ReadCount = 0
-		Dim lineArgs(3)
-
-		Do While Not stdin.AtEndOfLine
-			strLine = stdin.ReadLine()
-			strLine = unescape(trim(strLine))
-			
-			If IsNull(strLine) or strLine = "" Then
-				WScript.Quit 25127
-			End If
-
-			lineArgs(ReadCount) = strLine
-			
-			ReadCount = ReadCount + 1
-
-			If ReadCount = 4 Then
-
-				ParseHiveAndSubKey lineArgs(0), constHive, strSubKey
-				
-				if IsNull(constHive) Then
-					WriteLineErr "unsupported hive " & lineArgs(0)
-					WScript.Quit 25122
-				End If
-
-				strValueName = lineArgs(1)
-				strValue = lineArgs(2)
-				strType = lineArgs(3)
-				
-				Result = PutValue(constHive, strSubKey, strValueName, strValue, strType)
-
-				If Not Result = 0 Then
-					WriteLineErr "error while putting value: " & result
-					WScript.Quit Result
-				End If
-
-				ReadCount = 0
-				Erase lineArgs				
-			End If
-		Loop
-
-		If ReadCount <> 0 Then
-			WScript.Quit 25123
-		End If
-	</script>
-</job>

+ 0 - 358
bin/x64/vbs/regUtil.vbs

@@ -1,358 +0,0 @@
-' TODO: consider incorporating a json writer of some sort instead of adhoc solution like the following
-' e.g: http://demon.tw/my-work/vbs-json.html
-
-const HKEY_CLASSES_ROOT = &H80000000
-const HKEY_CURRENT_USER = &H80000001
-const HKEY_LOCAL_MACHINE = &H80000002
-const HKEY_USERS = &H80000003
-const HKEY_CURRENT_CONFIG = &H80000005
-
-Sub LoadRegistryImplementationByOSArchitecture()
-	If IsNull(OSArchitecture) Then
-		WriteLineErr "missing OSArchitecture global. did not call util.DetermineOSArchitecture? or Forgot to load util.vbs?"
-		WScript.Quit 25125		
-	End If
-
-	If OSArchitecture = "A" Then
-		Include "ArchitectureAgnosticRegistry.vbs"
-	Else
-		Include "ArchitectureSpecificRegistry.vbs"
-	End If
-End Sub 
-
-Function PutValue(constHive, strSubKey, strValueName, strValue, strType)
-	Select Case UCase(strType)
-		
-		Case "REG_SZ"
-			PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_EXPAND_SZ"
-			PutValue = SetExpandedStringValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_BINARY"
-			PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue))
-
-		Case "REG_NONE"
-			PutValue = SetBinaryValue(constHive, strSubKey, strValueName, ToBinaryValue(strValue))
-
-		' TODO: need to check that indeed int is the right type here
-		Case "REG_DWORD"
-			PutValue = SetDWORDValue(constHive, strSubKey, strValueName, CDbl(strValue))
-
-		Case "REG_MULTI_SZ"
-			PutValue = SetMultiStringValue(constHive, strSubKey, strValueName, Split(strValue, ","))
-
-		Case "REG_QWORD"
-			PutValue = SetQWORDValue(constHive, strSubKey, strValueName, strValue)
-
-		Case "REG_DEFAULT"
-			PutValue = SetStringValue(constHive, strSubKey, "", strValue)
-
-		Case Else
-			PutValue = SetStringValue(constHive, strSubKey, strValueName, strValue)
-
-	End Select
-End Function
-
-' render the child of a sub path strSubKey in hive constHive
-' as json.
-Sub ListChildrenAsJson(constHive, strSubKey)
-	' start outputting json to stdout
-	Write "{"
-
-	Dim e1: e1 = EnumKey (constHive, strSubKey, arrKeyNames)
-	If e1 <> 0 Then
-		Write """exists"": false,"
-		Dim arrValueNames: arrValueNames = null
-	Else
-		Write """exists"": true,"
-
-		Dim e2: e2 = EnumValues (constHive, strSubKey, arrValueNames, arrValueTypes)
-		If e2 <> 0 Then
-			WScript.Quit e2
-		End If
-	End If
-
-	Write """keys"": ["
-	If Not IsNull(arrKeyNames) Then
-		For x = 0 To UBound(arrKeyNames)
-			If (x > 0) Then
-				Write ","
-			End If
-	
-			Write """" & JsonSafe(arrKeyNames(x)) & """"
-		Next
-	End If
-	Write "],"
-	' TODO: some duplicity of code between the two paths of this condition, this needs to be address at some point
-	Write """values"":{"
-	If Not IsNull(arrValueNames) Then
-		For y = 0 To UBound(arrValueNames)
-			If y > 0 Then
-				Write ","
-			End If
-
-			strValueName = arrValueNames(y)
-			intValueType = arrValueTypes(y)
-			
-			' assign the value to varValue
-			GetValueByType constHive, strSubKey, strValueName, intValueType, varValue
-			
-			WriteValue strValueName, intValueType, varValue
-		Next
-	Else
-		' fix for keys with only default values in them
-		' see http://stackoverflow.com/questions/8840343/how-to-read-the-default-value-from-registry-in-vbscript
-		GetStringValue constHive, strSubKey, "", strDefaultValue
-
-		If IsNull(strDefaultValue) = false and strDefaultValue <> "" Then
-			' write the default value with REG_SZ
-			WriteValue "", 1, strDefaultValue
-		End If
-	End If
-	Write "}}"	
-End Sub
-
-Sub WriteValue (strValueName, intValueType, varValue)
-	Write """"  
-	Write JsonSafe(strValueName)
-	Write """:{"
-	Write """type"": """
-	Write RenderType(intValueType)
-	Write ""","
-	Write """value"":"
-	Write RenderValueByType(intValueType, varValue)
-	Write "}"
-End Sub
-
-' give a raw HKLM\something\somewhere
-' output the hive constant and the subkey, in this case:
-' HKEY_LOCAL_MACHINE will be assigned to outConstHive
-' and something\somewhere will be assigned to outStrSubKey
-Sub ParseHiveAndSubKey(strRawKey, outConstHive, outStrSubKey)	
-	' split into two parts to deduce the hive and the sub key
-	arrSplitted = Split(strRawKey, "\", 2, 1)
-	
-	If UBound(arrSplitted) > 0 Then
-		strHive = arrSplitted(0)	
-		outStrSubKey = arrSplitted(1)
-	Else
-		strHive = strRawKey
-		outStrSubKey = ""
-	End If
-
-	outConstHive = StringToHiveConst(UCase(strHive))
-End Sub
-
-Function ArrayRemoveAt(arr, pos)
-  Dim i
-  If IsArray(arr) Then
-    If pos >= 0 And pos <= UBound(arr) Then
-      For i = pos To UBound(arr) - 1
-        arr(i) = arr(i + 1)
-      Next
-      ReDim Preserve arr(UBound(arr) - 1)
-    End If
-  End If
-End Function
-
-Sub ParseHiveAndSubKeyAndValue(strRawKey, outConstHive, outStrSubKey, outStrValue)
-	' split into two parts to deduce the hive and the sub key
-	arrSplitted = Split(strRawKey, "\", -1, 1)
-
-	If UBound(arrSplitted) > 0 Then
-		strHive = arrSplitted(0)
-        outStrValue = arrSplitted(UBound(arrSplitted))
-        test = ArrayRemoveAt(arrSplitted, UBound(arrSplitted))
-        test = ArrayRemoveAt(arrSplitted, 0)
-        outStrSubKey = Join(arrSplitted, "\")
-	Else
-		strHive = strRawKey
-		outStrSubKey = ""
-	End If
-
-	outConstHive = StringToHiveConst(UCase(strHive))
-End Sub
-
-Function StringToHiveConst(strHive)
-	
-	Select Case strHive
-		Case "HKCR"
-			StringToHiveConst = HKEY_CLASSES_ROOT
-		Case "HKCU"
-			StringToHiveConst = HKEY_CURRENT_USER
-		Case "HKLM"
-			StringToHiveConst = HKEY_LOCAL_MACHINE
-		Case "HKU"
-			StringToHiveConst = HKEY_USERS
-		Case "HKCC"
-			StringToHiveConst = HKEY_CURRENT_CONFIG
-		Case Else
-			StringToHiveConst = Null	
-	End Select	
-
-End Function
-
-' TODO: this entire "by type" should be transformed into OOP style
-' where each type will have a class with render(), getValue() etc...
-
-' convert a value type number into a string label
-Function RenderType(intType)
-	RenderType = "REG_UNKNOWN"
-
-	Select Case intType
-		Case 0
-			RenderType = "REG_NONE"
-		Case 1
-			RenderType = "REG_SZ"
-		Case 2
-			RenderType = "REG_EXPAND_SZ"
-		Case 3
-			RenderType = "REG_BINARY"
-		Case 4
-			RenderType = "REG_DWORD"
-		Case 7
-			RenderType = "REG_MULTI_SZ"
-		Case 11	
-			RenderType = "REG_QWORD"
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)
-
-	End Select
-
-End Function
-
-' render by value type:
-' string will return as a string with double quotes, e.g "value"
-' multi string values which return as an array ot strings "["1", "2"]" (double quotes included ofc)
-' numeric values like DWORD and QWORD just return as the number e.g. 1
-' byte arrays such as reg_binary return as an array of ints, e.g [1,2,3]
-Function RenderValueByType(intType, varValue)
-
-	Select Case intType
-		' REG_NONE
-		Case 0
-			RenderValueByType = "0"
-
-		' REG_SZ
-		Case 1
-			RenderValueByType = """" & JsonSafe(varValue) & """"
-
-		' REG_EXPAND_SZ
-		Case 2
-			RenderValueByType = """" & JsonSafe(varValue) & """"
-
-		' REG_BINARY
-		Case 3
-			RenderValueByType = RenderByteArray(varValue)
-
-		' REG_DWORD
-		Case 4
-			RenderValueByType= varValue
-
-		' REG_MULYI_SZ'
-		Case 7
-
-			RenderValueByType = RenderStringArray(varValue)
-		' REG_QWORD
-		Case 11
-			RenderValueByType = varValue
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)
-	End Select
-
-End Function
-
-' get the value of a registry based on its value type and assign it to out parameter outVarValue
-Sub GetValueByType(constHive, strKey, strValueName, intType, outVarValue)
-
-	Select Case intType
-		' REG_NONE
-		Case 0
-			GetStringValue constHive, strKey, strValueName, "0"
-			Exit Sub
-
-		' REG_SZ
-		Case 1
-			GetStringValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-
-		' REG_EXPAND_SZ
-		Case 2
-			GetExpandedStringValue constHive, strKey, strValueName, outVarValue			
-			Exit Sub
-			
-		' REG_BINARY
-		Case 3
-			GetBinaryValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-			
-		' REG_DWORD
-		Case 4
-			GetDWORDValue constHive, strKey, strValueName, outVarValue
-
-			' #21 - VBS does not support UInt32. This is the workaround
-			If outVarValue < 0 Then outVarValue = 4294967296 + outVarValue
-
-			Exit Sub
-			
-		' REG_MULYI_SZ'
-		Case 7
-			GetMultiStringValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-			
-		' REG_QWORD
-		Case 11	
-			GetQWORDValue constHive, strKey, strValueName, outVarValue
-			Exit Sub
-		
-		Case Else
-			' TODO: should report / throw an error here
-			WriteErr("invalid Registry Value Type " & intType)	
-	End Select
-
-End Sub
-
-' render a byte array as a json array of numbers
-Function RenderByteArray(arr)
-	RenderByteArray = "[]"
-
-	If Not IsNull(arr) Then		
-		RenderByteArray = "[" & Join(arr, ",") & "]"
-	End If
-End Function
-
-' render a string array as json string array
-Function RenderStringArray(arr)	
-	Result = "["
-	If Not IsNull(arr) Then
-		For t = 0 To UBound(arr)
-			If (t > 0) Then
-				Result = Result &  ","
-			End If
-
-			Result = Result & """" & JsonSafe(arr(t)) & """"
-		Next
-	End If
-	Result = Result & "]"
-
-	RenderStringArray = Result
-End Function
-
-Function ToBinaryValue(strValue)
-
-	arrValue = Split(strValue, ",")
-	
-	If IsNull(arrValue) Then		
-		ToBinaryValue = Array()
-		Exit Function
-	End If
-
-	For i = 0 To UBound(arrValue)
-		arrValue(i) = CInt(arrValue(i))
-	Next
-
-	ToBinaryValue = arrValue
-End Function

+ 0 - 162
bin/x64/vbs/util.vbs

@@ -1,162 +0,0 @@
-Set stdout = WScript.StdOut
-Set stderr = WScript.StdErr
-Set stdin = WScript.StdIn
-Set args = WScript.Arguments
-Set fs = CreateObject("scripting.filesystemobject") 
-Dim OSArchitecture
-
-Sub WriteErr(message)
-	stderr.Write message
-End Sub
-
-Sub WriteLineErr(message)
-	stderr.WriteLine message
-End Sub
-
-Sub Write(message)
-	stdout.Write message
-End Sub
-
-Sub WriteLine(message)
-	stdout.WriteLine message
-End Sub
-
-Function IndexOf(varNeedle, arrHaystack)
-	IndexOf = -1
-	
-	If Not IsArray(arrHaystack)	 Then
-		Exit Function
-	End If
-
-	For xyz = 0 To UBound(arrHaystack)
-		If arrHaystack(xyz) = varNeedle Then
-			IndexOf = xyz
-			Exit Function
-		End If
-	Next
-End Function
-
-Sub CheckZeroArgs(message)
-	' bail if args are missing
-	If args.Count = 0 Then
-		WriteLineErr message
-		WScript.Quit 25121
-	End If
-End Sub
-
-Dim ALLOWED_OS_ARCHITECTURE_VALUES: ALLOWED_OS_ARCHITECTURE_VALUES = Array("S", "A", "32", "64")
-
-'
-'	determine the architecture of the operating system, that will be used. there are 4 possibilities:
-'	A - means agnostic
-'	S - means that we want to use a specific architecture, but auto detect Item
-'	32 - explicitly use 32 bit architecture
-'	64 - explicitly use 64 bit architecture
-'
-Sub DetermineOSArchitecture()
-	strArchitecture = args(0)
-
-	If IsNull(strArchitecture) Then
-		WriteLineErr "missing architecture argument"
-		WScript.Quit 25124
-	End If
-
-	strArchitecture = UCase(strArchitecture)
-
-	If IndexOf(strArchitecture, ALLOWED_OS_ARCHITECTURE_VALUES) = -1 Then
-		WriteLineErr "invalid architecture argument"
-		WScript.Quit 25124
-	End If
-
-	If (strArchitecture = "S") Then
-		OSArchitecture = GetOSArchitecture()
-		If OSArchitecture = -1 Then
-			WriteLineErr "invalid os architecture detected " & OSArchitecture
-			WScript.Quit 25126
-		End If
-	Else
-		OSArchitecture = strArchitecture
-	End If
-
-End Sub
-
-Sub Include(sPath)
-	' TODO this is fragile, but should work for "modules" nested relatively to script root
-	include_ScriptPath = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName) - 2)	
-	sPath = include_ScriptPath & "\" & sPath
-	
-	include_code = fs.OpenTextFile(sPath).ReadAll 	
-	ExecuteGlobal include_code
-End Sub
-
-Function GetOSArchitecture()
-
-	Dim ObjWMI, ColSettings, ObjProcessor 
-	Dim StrComputer, ObjNetwork 
-	
-	Set ObjWMI = GetObject("winmgmts:\Root\CIMV2") 
-	Set ColSettings = ObjWMI.ExecQuery ("SELECT DataWidth, AddressWidth, Architecture FROM Win32_Processor") 
-
-	' TODO: I make two assumptions here: 
-	' 1. Eveyone will have CPU0 device
-	' 2. There is only one cpu defined in the wmi database (and if not, then they are all of the same architecture)
-	Set ObjProcessor = ColSettings.Item("Win32_Processor.DeviceID=""CPU0""")
-
-	If ObjProcessor.Architecture = 0 AND ObjProcessor.AddressWidth = 32 Then 
-		GetOSArchitecture = 32
-	ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 32 Then 
-		GetOSArchitecture = 32
-	ElseIf (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 
-		GetOSArchitecture = 64
-	Else		
-		GetOSArchitecture = -1
-	End If 
-	
-End Function
-
-Function JsonSafe(outStrText)
-	If outStrText = "" Then
-		JsonSafe = ""
-		Exit Function 
-	End If
-		
-	outStrText = Replace(outStrText, "\", "\\")
-	outStrText = Replace(outStrText, vbcrlf, "\\r\\n")
-	outStrText = Replace(outStrText, vblf, "\\n")
-	outStrText = Replace(outStrText, vbcr, "\\r")
-	outStrText = Replace(outStrText, """", "\""")	
-	outStrText = JsonU(outStrText)
-	JsonSafe = outStrText
-End Function
-
-'TODO: need to change this function's name to something more appropriate
-Function JsonU(astr)
-	
-	If isNull(astr) Then
-		JsonU = ""
-		Exit Function
-	End If
-
-	Dim c 
-	Dim utftext: utftext = ""
-	
-	For n = 1 To Len(astr)
-		c = CLng(AscW(Mid(astr, n, 1)))
-
-		If c < 0 Then
-			c = &H10000 + c
-		End If
-
-		If c < &H80 Then
-			utftext = utftext & Mid(astr, n, 1)
-		ElseIf c < &H100 Then
-			utftext = utftext & "\u00" & Hex(c)
-		ElseIf c < &H1000 Then
-			utftext = utftext & "\u0" & Hex(c)
-		Else
-			utftext = utftext & "\u" & Hex(c)
-		End If
-	Next
-
-	JsonU = utftext
-End Function

+ 1 - 1
src/index.ejs

@@ -2,7 +2,7 @@
 <html>
   <head>
     <meta charset="utf-8">
-    <title>星优频助手</title>
+    <title>星优频助手</title>
     <% if (htmlWebpackPlugin.options.nodeModules) { %>
       <!-- Add `node_modules/` to global paths so `require` works properly in development -->
       <script>

+ 222 - 14
src/renderer/components/home.vue

@@ -329,16 +329,29 @@
 							</div>
 							
 							<!-- 6音频消音 -->
-							<div class="handle-item" v-if="menuIndex == '6'">
+							<div class="handle-item remove" v-if="menuIndex == '6'">
 								<label class="handle-label">去除声音:</label>
-								<el-checkbox v-model="handleData.audioRemove"></el-checkbox>
+								<el-checkbox v-model="handleData.audioRemove" disabled></el-checkbox>
 								<el-input-number size="small" disabled style="opacity: 0;"></el-input-number>
 							</div>
 							
 							<!-- 7视频变速 -->
 							<div class="handle-item" v-if="menuIndex == '7'" style="margin-bottom: 5px;">
-								<label class="handle-label">播放速度:</label>
-								<el-slider class="info-input" v-model="handleData.speed" :min="0.5" :max="2.0" :step="0.05" style="margin-right: 10px;"></el-slider> {{handleData.speed}}倍
+								<label class="handle-label">选择设置:</label>
+								<el-radio-group v-model="handleData.reverseSet" size="small">
+									<el-radio-button :label="1" >变速</el-radio-button>
+									<el-radio-button :label="2" >倒放</el-radio-button>
+								</el-radio-group>
+								<template v-if="handleData.reverseSet == 1">
+									<label class="handle-label">播放速度:</label>
+									<el-slider class="info-input" v-model="handleData.speed" :min="0.5" :max="2.0" :step="0.05" style="margin-right: 10px;"></el-slider> {{handleData.speed}}倍
+								</template>
+								<template v-else>
+									<label class="handle-label">视频倒放:</label>
+									<el-checkbox v-model="handleData.reverse"></el-checkbox>
+									<label class="handle-label">声音倒放:</label>
+									<el-checkbox v-model="handleData.areverse"></el-checkbox>
+								</template>
 							</div>
 							
 							<!-- 8音量调整 -->
@@ -602,7 +615,12 @@ export default {
 				auto_pinlv: 16000,
 				auto_channel: 1,
 				
-				audioRemove: false,
+				audioRemove: true,
+				speed: 1.5,
+				volume: 1.5,
+				reverseSet: 1,
+				reverse: true,
+				areverse: true,
 				audioQuality: '-1',
 				videoQuality: '0.5',
 			},
@@ -720,7 +738,12 @@ export default {
 				auto_pinlv: 16000,
 				auto_channel: 1,
 				
-				audioRemove: false,
+				audioRemove: true,
+				speed: 1.5,
+				volume: 1.5,
+				reverseSet: 1,
+				reverse: true,
+				areverse: true,
 				audioQuality: '-1',
 				videoQuality: '0.5',
 			};
@@ -1352,13 +1375,8 @@ export default {
 						
 						//audioQuality
 						let baArr = [];
-						let audioArr = [];
-						if(this.handleData.audioRemove){
-							audioArr = ['-an'];
-						}else{
-							if(this.handleData.audioQuality != '-1'){
-								baArr = ['-b:a', this.handleData.audioQuality+'k']
-							}
+						if(this.handleData.audioQuality != '-1'){
+							baArr = ['-b:a', this.handleData.audioQuality+'k']
 						}
 						
 						if(file.rotate == '90'){
@@ -1397,7 +1415,192 @@ export default {
 							'ultrafast',
 							...bvArr,  // 码率
 							...baArr,
-							...audioArr,
+							outPath,
+							'-hide_banner',
+							'-y'
+						];
+					
+						electronApi.spawnExec(cmds,{
+							stderr:(data) =>{
+								let timeStr = regexTime.exec(data.toString());
+								if(timeStr && timeStr[1]){
+									file.percent = Math.ceil((this.getSs(timeStr[1])/file.duration).toFixed(2) * 100);
+									if(file.percent < 1){
+										file.percent = 1;
+									}
+									if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+										this.videoList.splice(index, 1, file);
+									}
+								}
+							}
+						}).then(res => {
+							file.percent = 100
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								this.videoList.splice(index, 1, file);
+							}
+							resolve(true);
+						}).catch(err =>{
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								file.percent = 0 // 失败则进度设置为0
+								this.videoList.splice(index, 1, file);
+							}
+							this.$notify.error({
+								title: '文件错误',
+								message: '视频参数有误,请修后再试! '+ file.path,
+							});
+							resolve(true);
+						})
+					})
+					break;
+				case '6': // 视频消音
+					task = new Promise((resolve,reject) =>{
+						let filePath = file.path;
+						let suffix =  filePath.slice(filePath.lastIndexOf('.')+1);
+						let outPath = this.handleData.newPath + "\/" + file.name.slice(0, file.name.lastIndexOf('.')) + '.'+suffix;
+					
+						let params = [];
+						params.push('-i'); //'-i', filePath, 
+						params.push(filePath);
+						
+						let cmds = [
+							'ffmpeg.exe',
+							'-i',
+							filePath,
+							'-preset',
+							'ultrafast',
+							'-an',
+							'-vcodec',
+							'copy',
+							outPath,
+							'-hide_banner',
+							'-y'
+						];
+					
+						electronApi.spawnExec(cmds,{
+							stderr:(data) =>{
+								let timeStr = regexTime.exec(data.toString());
+								if(timeStr && timeStr[1]){
+									file.percent = Math.ceil((this.getSs(timeStr[1])/file.duration).toFixed(2) * 100);
+									if(file.percent < 1){
+										file.percent = 1;
+									}
+									if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+										this.videoList.splice(index, 1, file);
+									}
+								}
+							}
+						}).then(res => {
+							file.percent = 100
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								this.videoList.splice(index, 1, file);
+							}
+							resolve(true);
+						}).catch(err =>{
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								file.percent = 0 // 失败则进度设置为0
+								this.videoList.splice(index, 1, file);
+							}
+							this.$notify.error({
+								title: '文件错误',
+								message: '视频参数有误,请修后再试! '+ file.path,
+							});
+							resolve(true);
+						})
+					})
+					break;
+				case '7': // 视频变速\倒放
+					task = new Promise((resolve,reject) =>{
+						let filePath = file.path;
+						let suffix =  filePath.slice(filePath.lastIndexOf('.')+1);
+						let outPath = this.handleData.newPath + "\/" + file.name.slice(0, file.name.lastIndexOf('.')) + '.'+suffix;
+					
+						let params = [];
+						params.push('-i'); //'-i', filePath, 
+						params.push(filePath);
+						
+						let audioNumber = this.handleData.speed;
+						let videoNumber = 1 / this.handleData.speed;
+						
+						let v_arr = [];
+						let a_arr = [];
+						let s_arr = [];
+						if(this.handleData.reverseSet == 1){ // 变速
+							s_arr = ['-filter_complex',"[0:v]setpts="+videoNumber+"*PTS[v];[0:a]atempo="+audioNumber+"[a]",'-map', "[v]",'-map',"[a]"];
+						}else if(this.handleData.reverseSet == 2){ // 倒放
+							if(this.handleData.reverse){ // 视频倒放
+								v_arr = ['-vf', 'reverse'];
+							}
+							if(this.handleData.areverse){ // 音频倒放
+								a_arr = ['-af', 'areverse'];
+							}
+						}
+						
+						let cmds = [
+							'ffmpeg.exe',
+							'-i',
+							filePath,
+							'-preset',
+							'ultrafast',
+							...s_arr,
+							...v_arr,
+							...a_arr,
+							outPath,
+							'-hide_banner',
+							'-y'
+						];
+					
+						electronApi.spawnExec(cmds,{
+							stderr:(data) =>{
+								let timeStr = regexTime.exec(data.toString());
+								if(timeStr && timeStr[1]){
+									file.percent = Math.ceil((this.getSs(timeStr[1])/file.duration).toFixed(2) * 100);
+									if(file.percent < 1){
+										file.percent = 1;
+									}
+									if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+										this.videoList.splice(index, 1, file);
+									}
+								}
+							}
+						}).then(res => {
+							file.percent = 100
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								this.videoList.splice(index, 1, file);
+							}
+							resolve(true);
+						}).catch(err =>{
+							if(this.videoList[index]){ // 运行中的数据 删除后 防止重新添加
+								file.percent = 0 // 失败则进度设置为0
+								this.videoList.splice(index, 1, file);
+							}
+							this.$notify.error({
+								title: '文件错误',
+								message: '视频参数有误,请修后再试! '+ file.path,
+							});
+							resolve(true);
+						})
+					})
+					break;
+				case '8': // 视频音量调整
+					task = new Promise((resolve,reject) =>{
+						let filePath = file.path;
+						let suffix =  filePath.slice(filePath.lastIndexOf('.')+1);
+						let outPath = this.handleData.newPath + "\/" + file.name.slice(0, file.name.lastIndexOf('.')) + '.'+suffix;
+					
+						let params = [];
+						params.push('-i'); //'-i', filePath, 
+						params.push(filePath);
+						
+						let cmds = [
+							'ffmpeg.exe',
+							'-i',
+							filePath,
+							'-preset',
+							'ultrafast',
+							'-af',
+							"volume="+this.handleData.volume,
+							'-c:v',
+							'copy',
 							outPath,
 							'-hide_banner',
 							'-y'
@@ -1869,4 +2072,9 @@ export default {
 			border-top-right-radius: 8px;
 		}
 	}
+	
+	.remove .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
+	    background-color: #409EFF;
+		border-color: #409EFF;
+	}
 </style>