Solved

ODBC VBS Scripts not showing in ODBS Administrator

Posted on 2007-11-20
5
813 Views
Last Modified: 2013-11-23
I have three VBS scripts that run when a user logs into a workstation. The scripts enter in values for ODBC Drivers that are needed for our ERP system.

The problem I am having is the scripts run, the registry entries are enter into the registry but the they do not show in the ODBC Administrator so our ERP system does not see them.

What changes do I need to make for when the script executes the entries will show in the ODBC Administrator?

'This is the code for the .vbs script that run at user login
'File name is CRGUP.vbs
 
Const HKEY_LOCAL_MACHINE = &H80000002
 
strComputer = "."
 
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _ 
    strComputer & "\root\default:StdRegProv")
 
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources"
strValueName = "CRGUP"
strValue = "CR SQLBase"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\CRGUP"
 
objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
 
strKeyPath = "SOFTWARE\ODBC\ODBC.INI\CRGUP"
 
strValueName = "Database"
strValue = "CFI"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "Description"
strValue = "Visual"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "LogonID"
strValue = "SYSADM"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "Driver"
strValue = "C:\WINDOWS\system32\crgup13.dll"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "InputMessageSize"
strValue = "0"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "Timout"
strValue = "300"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "NoRecovery"
strValue = "0"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "ReleasePlan"
strValue = "0"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "ServerName"
strValue = "server1"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "Servers"
strValue = ""
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "ApplicationUsingThreads"
strValue = "1"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
strValueName = "CursorCacheSize"
strValue = "6"
objReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
 
'Below are the registry entries
'File name is CRGUP.reg
REGEDIT4
 
[HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\CRGUP]
"Database"="CFI"
"Description"="Visual"
"LogonID"="SYSADM"
"Driver"="C:\\WINDOWS\\system32\\crgup13.dll"
"InputMessageSize"="0"
"Timout"="300"
"NoRecovery"="0"
"ReleasePlan"="0"
"ServerName"="server1"
"Servers"=""
"ApplicationUsingThreads"="1"
"CursorCacheSize"="6"

Open in new window

0
Comment
Question by:TheMetrix
  • 3
  • 2
5 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 20323902
Hi, if you have the CRGUP.reg file already created (and tested whether just importing this allows the connection to appear in ODBC), then you should only need that reg file located on a network share, then use the following VBS:

Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c regedit /s \\server\share\CRGUP.reg", 0, True

Regards,

Rob.
0
 
LVL 5

Author Comment

by:TheMetrix
ID: 20328427
That worked great Rob, Thanks!!!!!

One more thing though. This is a domain system, I have users that are not local admin or Power Users so the .reg file is not imported. I've allowed the use of registry tools but those logins still do not let the .reg file import. Any suggestions?
0
 
LVL 5

Author Comment

by:TheMetrix
ID: 20328487
I guess what I am trying to find is to still leave the user as normal user but run the logon scripts with a higher priv level.
0
 
LVL 5

Author Comment

by:TheMetrix
ID: 20329448
I put the script in the computer configuration script start up instead and it works great!!!

Again thanks Rob, you are a life save bro.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20330778
Hi, no problem!  Sorry I couldn't get back to you earlier, that's the problem with being on the other side of the world I suppose!

Anyway, yes, making this a StartUp script would work for two reasons:
1) A StartUp script runs under the local System account, meaning it has full control over the local computer, and can access only the NetLogon share of a domain controller, in terms of Network Access.
2) The registry keys are HKLM, and *not* HKCU.  This means that the keys apply to the whole computer.  If the keys had to be HKCU, the System account would not know which user to apply it to, because no user has logged in yet.

Regards,

Rob.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to make an ADE file by code? 11 83
ERP application comparison 1 24
VBA & VBSCRIPT: re-adapt log file 13 26
VB Script: Correction backup files and folders v3 11 25
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question