set ws = CreateObject("Wscript.shell")

sCurrentDir = ws.currentdirectory

set args      = wscript.arguments
sBinariesPath = args(0) ' path to binaries dir
sRazzlePath   = args(1) ' path to razzle
sTarget       = args(2) ' target folder
sPlatform     = args(3) ' machine architecture [i386|ia64|amd64]

' getting the binaries path into a format usable by the query
sLastPart = mid(sBinariesPath ,3, len(sBinariesPath )-2)
sBinariesPath = "\" & sLastPart

set svc = getObject("Winmgmts:root\cimv2")
sQuery = "select * from win32_directory where path = '" & sBinariesPath & "\\components\\' and name like '%wevtviewer%' "
set objEnum = svc.execQuery(sQuery, "WQL", 0)
for each obj in objenum
	sName = obj.name
	sDrive = obj.drive
next

set obj = svc.get("win32_process")
sCommand = "cmd /k " & sRazzlePath & "\razzle.cmd exec " & sDrive & " && cd " & sCurrentDir & "&& CopyViewer.cmd " & sTarget & " " & sName & " " & sPlatform & " && exit"
obj.create(sCommand)

'set svc = getObject("Winmgmts:root\cimv2")
'sQuery = "select * from win32_directory where path = '" & sBinariesPath & "\\components\\' and name like '%ViewerInstall%' "
'set objEnum = svc.execQuery(sQuery, "WQL", 0)
'for each obj in objenum
	'sName = obj.name
	'sDrive = obj.drive
'next

'set obj = svc.get("win32_process")
'sCommand = "cmd /k " & sRazzlePath & "\razzle.cmd exec " & sDrive & " && cd " & sCurrentDir & "&& CopyVInstall.cmd " & sTarget & " " & sName & " " & sPlatform & " && exit"
'obj.create(sCommand)

