Dim oWsh, oFSO, nReturnCode, sNSISScriptPath, sNSISScriptFileName, sNSISScriptFullPath
Set oFSO = CreateObject("Scripting.FileSystemObject")

sNSISScriptPath = oFSO.GetFile(Wscript.ScriptFullName).ParentFolder 

sNSISScriptFileName = "rc_player_online.nsi"
sNSISScriptOutFileName = "rc_player_online.exe"

sNSISScriptFullPath = sNSISScriptPath & "\" & sNSISScriptFileName					'"
sNSISScriptOutFullPath = sNSISScriptPath & "\" & sNSISScriptOutFileName				'"

Const HKEY_LOCAL_MACHINE = &H80000002

Dim sPath
sPath = ReadRegStr (HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Uninstall\NSIS", "InstallLocation", 32)

If (isNull(sPath)) Then
	WScript.Quit(2)
End If


Set oWsh = WScript.CreateObject ("WScript.Shell") 
command = """" & sPath & "\makensis.exe"" """ & sNSISScriptFullPath & """"
nReturnCode = oWsh.Run(command, 0, True)

Set oWsh = Nothing

WScript.Quit(nReturnCode)

'-----------------------------------------------------------'

Function ReadRegStr (RootKey, Key, Value, RegType)
	Dim oCtx, oLocator, oReg, oInParams, oOutParams

	Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
	oCtx.Add "__ProviderArchitecture", RegType

	Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
	Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")

	Set oInParams = oReg.Methods_("GetStringValue").InParameters
	oInParams.hDefKey = RootKey
	oInParams.sSubKeyName = Key
	oInParams.sValueName = Value

	Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)

	ReadRegStr = oOutParams.sValue
End Function