Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Thanks for all previous help! I have a question regarding av script.

My computers is all XP, and needs the following when I do my thing :

I have 2 ODBC-connections (towards MS-SQL-DB), which I have a username / password to create a connection to.

Does anyone have any advice on how to accomplish this? Either in a batch-script or otherwise.

share|improve this question

I'll recomend to use Windows Scripting (WSH) or Windows powerShell.

The reason are:

  • you will probably get more use for that tecnology in a Windows enviroment than of python. (I like python but this is true)
  • It's included in all Windows Version (the scripting tecnology).
  • You can do a lot of things in a easy way... check WMI, services, restarts, manage logs, files, odbcs, external software, uninstall software...

There's many Web with sample scripts, and a blog of microsoft with a lot of information: Scripting Web And they provide a free tool to help you in programming and with a lot of examples: Scriptomatic 2.0

And now, the Solution.

First of all, you need Mysql ODBC driver installed in the XP

Then, Here's a link of a sample code, that explain how works and that you can configure to your needs.

Example Script

For executing those scripts, simply open a CMD window and use the command: cscript script.vbs

As you can see, the solution is in the same web that told before, there's a huge database and can do anything with them.

Hope this helps.

share|improve this answer
Mysql odbc driver? not mssql? Thanks for all the advice. I promise you that I will not go with Python. Windows Powershell or vbs maybe? I have to sit down a weekend to learn vbs. Maybe drink some beer and learn vbs. Or just drink beer. :-) – Maclovin May 20 '11 at 7:05
if MSSQL database, You didnt have to install the odbc, it's included on Windows, I'm more confortable with Vbscript at the moment, but Powershell is powerful too. Both choices are good. Luck! – Carlos Garcia May 23 '11 at 16:00

What do you need to do?

If all you have to do is to check if both databases are in good condition then write simple program that checks that. You can use Python with odbc module; it is already included if you use Python from ActiveState:

You test script can look like:

import odbc
connection = odbc.odbc('DSN[/username[/password]]')
cursor = connection.cursor()
cursor.execute("SELECT ...")
for txt in cursor.fetchall():

Of course you can use such program from .bat my_database1/maclovin/passwd my_database2/maclovin/passwd

and in program use connect string from command line: odbc.odbc(sys.argv[1]) (in such case you must also import sys)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.