'region Script Settings
'<ScriptSettings xmlns="http://tempuri.org/ScriptSettings.xsd">
'  <ScriptPackager>
'    <process>cscript.exe</process>
'    <arguments />
'    <extractdir>%TEMP%</extractdir>
'    <files />
'    <usedefaulticon>true</usedefaulticon>
'    <showinsystray>false</showinsystray>
'    <altcreds>false</altcreds>
'    <efs>true</efs>
'    <ntfs>true</ntfs>
'    <local>false</local>
'    <abortonfail>true</abortonfail>
'    <product />
'    <version>1.0.0.1</version>
'    <versionstring />
'    <comments />
'    <includeinterpreter>false</includeinterpreter>
'    <forcecomregistration>false</forcecomregistration>
'    <consolemode>false</consolemode>
'    <EnableChangelog>false</EnableChangelog>
'    <AutoBackup>false</AutoBackup>
'    <snapinforce>false</snapinforce>
'    <snapinshowprogress>false</snapinshowprogress>
'    <snapinautoadd>0</snapinautoadd>
'    <snapinpermanentpath />
'  </ScriptPackager>
'</ScriptSettings>
'endregion

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshProcEnv = WshShell.Environment("PROCESS")

boolAuth = WshProcEnv("CHATPARAM_1")
strServer = WshProcEnv("CHATPARAM_2")
strUser = WshProcEnv("CHATPARAM_3") 
strPassword = WshProcEnv("CHATPARAM_4")

'boolAuth = 1
'strServer = "FUJI"
'strUser = "tester" 
'strPassword = "test"

On Error Resume Next
TryAccess
AccessDenied

Sub TryAccess()
	If boolAuth = "T" Then
		cnstring = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Data Source=" & strServer & ";User ID=;Password="
	Else
		cnstring = "Provider=SQLOLEDB;Persist Security Info=False;User ID=" & strUser & ";Data Source=" & strServer & ";Password=" & strPassword & ";"
	End If
	Set cn = CreateObject("adodb.connection") 
	cn.connectionstring = cnstring 
	cn.Open 
		WScript.StdOut.WriteLine
		WScript.StdOut.WriteLine "CHATVAR_SQLaccess=1" & Chr(0)
	cn.Close
	WScript.Quit(0)
End Sub

Sub AccessDenied()	
	WScript.StdOut.WriteLine "CHATVAR_SQLaccess=0" & Chr(0)
End Sub

	





