Dim DataSourceName
Dim DatabaseName
Dim Description
Dim DriverPath
Dim DriverName
Dim LastUser
Dim Password
Dim Server
  
Const HKEY_LOCAL_MACHINE  = &H80000002

Dim RegEdPath

Function KeyExists(Key, KeyPath)
    Dim oReg: Set oReg = GetObject("winmgmts:!root/default:StdRegProv")
    If oReg.EnumKey(Key, KeyPath, arrSubKeys) = 0 Then
        KeyExists = True
    Else
        KeyExists = False
    End If
End Function

Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")

' Check if the DSN already exists, and if so, exit the script.
If oReg.EnumKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\EZPRO_ARC", "", "") = 0 Then
    wscript.Quit
End If

' Specify the DSN parameters.
DataSourceName = "EZPRO_ARC"
DatabaseName = "EZPRO_ARC"
Description = "EZPRODatabase"
Server = "10.0.0.4\ECOMLLC"
LastUser  = "Sunshine"
Password = "Sunsh1neK@RC"
DriverName = "SQL Server"

Set WshShell = WScript.CreateObject("WScript.Shell")

' 64-bit machine: Use System32 for 64-bit drivers.
DriverPath = "c:\Windows\System32\sqlncli10.dll" ' Path for 64-bit SQL Native Client driver
RegEdPath = "HKLM\SOFTWARE\ODBC\ODBC.INI\EZPRO_ARC\"

' Create or update the DSN registry entry for EZPRO_ARC
WshShell.RegWrite RegEdPath & "Database", DatabaseName
WshShell.RegWrite RegEdPath & "Description", Description
WshShell.RegWrite RegEdPath & "Driver", DriverPath
WshShell.RegWrite RegEdPath & "Server", Server
WshShell.RegWrite RegEdPath & "Trusted_Connection", "NO"

' Add the Data Source to ODBC Data Sources
WshShell.RegWrite "HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\" & DataSourceName, DriverName

wscript.Quit
