'Create the Filesystem Object
Const SystemFolder= 1
Set oFso = CreateObject("Scripting.FileSystemObject")
Set SysFolder =oFso.GetSpecialFolder(SystemFolder)
SysFolderPath= SysFolder.Path
'Set the Driver details
DriverPath = SysFolderPath & "\sqora32.dll"
DriverName = "Oracle in Oraclient11g_home4"
'get the required details
DataSourceName = "Sample Source Name"
DatabaseName = "DB Name"
sDescription = "Odbc Desc " & DatabaseName
tnsNames = "Tns Names"
userId = "User name"
'Create Shell Object
Set WshShell = CreateObject("WScript.Shell")
'Set the Key in the register of DSN
RegEdPath= "HKLM\SOFTWARE\ODBC\ODBC.INI\" & DataSourceName & "\"
'We recorded
WshShell.RegWrite RegEdPath , ""
'We put the values of the new Key for the DSN
WshShell.RegWrite RegEdPath & "Database" , DatabaseName
WshShell.RegWrite RegEdPath & "Description" , sDescription
WshShell.RegWrite RegEdPath & "Driver" , DriverPath
WshShell.RegWrite RegEdPath & "LastUser" , userId
WshShell.RegWrite RegEdPath & "Server" , tnsNames
'Update the Registry
WshShell.RegWrite "HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\" & DataSourceName , DriverName
Const SystemFolder= 1
Set oFso = CreateObject("Scripting.FileSystemObject")
Set SysFolder =oFso.GetSpecialFolder(SystemFolder)
SysFolderPath= SysFolder.Path
'Set the Driver details
DriverPath = SysFolderPath & "\sqora32.dll"
DriverName = "Oracle in Oraclient11g_home4"
'get the required details
DataSourceName = "Sample Source Name"
DatabaseName = "DB Name"
sDescription = "Odbc Desc " & DatabaseName
tnsNames = "Tns Names"
userId = "User name"
'Create Shell Object
Set WshShell = CreateObject("WScript.Shell")
'Set the Key in the register of DSN
RegEdPath= "HKLM\SOFTWARE\ODBC\ODBC.INI\" & DataSourceName & "\"
'We recorded
WshShell.RegWrite RegEdPath , ""
'We put the values of the new Key for the DSN
WshShell.RegWrite RegEdPath & "Database" , DatabaseName
WshShell.RegWrite RegEdPath & "Description" , sDescription
WshShell.RegWrite RegEdPath & "Driver" , DriverPath
WshShell.RegWrite RegEdPath & "LastUser" , userId
WshShell.RegWrite RegEdPath & "Server" , tnsNames
'Update the Registry
WshShell.RegWrite "HKLM\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources\" & DataSourceName , DriverName
Comments