vbs script to create ODBC system DSN works in XP but not Windows 7

I have a vbs script (below) that creates an ODBC system DSN that's been working nicely on Windows XP for years. Unfortunately it no longer works on Windows 7. The software that uses the connection is 32 bit, and I've successfully created the appropriate 32 bit system DSN manually by running:

I haven't done that, but there appears to be no administrator option available. I'm logged in as a user with administrator privileges, so I don't know why it's not there. Here's a screenshot of the available options:

I'm trying to overcome this as well. I have a VBA function from Access that used to do the same thing. It has something to do User Account Control. I'm sort of stretched thin at the moment -- but if you or I can find it -- it will help both of us.

Try this. Create a shortcut to the script on your desktop. RIght-click the shortcut, then click Properties. Click the Shortcut tab, if it's not already selected. Click the Advanced button. There should be a checkbox to Run As Administrator. This should work for any application, the only exception I've seen up to this point is Office 2010 shortcuts.

It was clear that my manually created 32-bit DSN's included "Wow6432Node" as part of the path, but it wasn't clear whether I had to specify that as part of the path when creating the registry entries. When Windows runs applications in 32-bit mode, it automatically adds "Wow6432Node" to the registry path to get values, so it would make some sense for it to be automatically added when writing to the registry too. However, it did turn out that I had to manually include Wow6432Node as part of the registry path when writing to the registry.

The functions within my script were suppressing errors, so by commenting out the lines containing "On Error Resume Next : Err.Clear()", I could see when an error occurred. This was helpful, but not the solution.

It was suggested to me that I might need to run the .vbs script with the 32-bit Windows script engine, in which case the script would need to be passed to C:\Windows\SysWOW64\wscript.exe, which is not the default engine. To achieve this, I created a shortcut to the .vbs script, alter the properties of the shortcut so the .vbs script is passed to the 32-bit script engine, like this:
Changing the shortcut to point to the script engine made the "Run as administrator" appear in the context menu, and when I used that option the script worked. It turns out that it still worked when I just added wscript.exe to the target (which Windows automatically updates to C:\Windows\System32\wscript.exe upon saving the change) so the 32-bit scripting engine was not actually required. The key thing was getting the Run as Administrator option to appear.

Note that a .bat file containing:
wscript.exe "C:\myscript.vbs"
would probably work equally well, as long as it's Run As Administrator. I tried this quite early on I think, but the error suppression in my script hid the errors I needed to see.

Thanks all for your help - it did get me pointed in the right direction at least.

2 key parts of the answer I solved myself were adding wscript.exe to the shortcut, and commenting out the error suppression in the .vbs file. Thanks all... you did get me pointed in the right direction at least.

0

Featured Post

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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 …

Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously.
This will be demonstrated using Windows 7 operating…