Couldn't get enough time to update solution for this problem. I was following some real tight schedule.
but here we go.
First of all,
You can not access any documents/files from Client machine without any user interventions. Period.
Fairly because of Security Issues and its quite understandable.
Even though if you want to achieve it any how, then VBScript will be the best solution that will come handy.
Just posting the VBScript code to read ODBC DSN list entries from client system and store it in an XML file, if anyone is interested in future.
option explicit
const HKLM = &H80000001
dim keyPath, subKeyPath
keyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
subKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
dim reg, subReg
dim valueNames, types, arrValueNames, arrValueTypes
dim subValueNames, subArrValueNames, subArrValueTypes
dim value
value = "SQL Server"
dim subValue
subValue = "server"
dim i, k
'Create XML file from this where we'll be storing ODBC Connections Parameters
dim xmlDoc, objRoot, objName, objServerName, objDBName, objIntro
Set xmlDoc = _
CreateObject("Microsoft.XMLDOM")
'DBDetails element
Set objRoot = _
xmlDoc.createElement("DBDetails")
xmlDoc.appendChild objRoot
set reg = getObject( "Winmgmts:root\default:StdRegProv" )
reg.EnumValues HKLM, keyPath, arrValueNames, arrValueTypes
For i = 0 to Ubound(arrValueNames)
valueNames = arrValueNames(i)
reg.GetStringValue HKLM, keyPath, valueNames, value
IF value = "SQL Server" THEN
'Create Element for this DB and add values as sub nodes
Set objName = _
xmlDoc.createElement("DB" & i)
objRoot.appendChild objName
set subReg = getObject( "Winmgmts:root\default:StdRegProv" )
subReg.EnumValues HKLM, "SOFTWARE\ODBC\ODBC.INI\" & valueNames, subArrValueNames, subArrValueTypes
for k = 0 to Ubound(subArrValueNames)
subValueNames = subArrValueNames(k)
reg.GetStringValue HKLM, "SOFTWARE\ODBC\ODBC.INI\" & valueNames, subValueNames, subValue
'Wscript.Echo subValueNames & " -- " & subValue
'Server Name Node
If subValueNames = "Server" Then
Set objServerName = _
xmlDoc.createElement("ServerName")
objServerName.Text = subValue
objName.appendChild objServerName
End If
'DB Name Node
If subValueNames = "Database" Then
Set objDBName = _
xmlDoc.createElement("DatabaseName")
objDBName.Text = subValue
objName.appendChild objDBName
End If
Next
End If
Next
Set objIntro = _
xmlDoc.createProcessingInstruction _
("xml","version='1.0'")
xmlDoc.insertBefore _
objIntro,xmlDoc.childNodes(0)
If(WScript.CreateObject("Scripting.FileSystemObject").FolderExists("C:\TravcomTouch") = False) Then
WScript.CreateObject("Scripting.FileSystemObject").CreateFolder("C:\TravcomTouch")
End If
xmlDoc.Save "C:\Test\ODBCDBDetails.xml"
Hope it will be helpful to someone !!!