最近要用一下Oracle instantclient的ODBC,由于配置有点繁琐,于是打算用vbs写一脚本来自动化一下,刚开始是这样的:

Set ws = CreateObject("WScript.Shell") ws.Exec("C:/instantclient_11_1/odbc_install.exe") Set ws = Nothing

但是怎么也装不上,于是在dos下试了下:

C:/Documents and Settings/dxl>C:/instantclient_11_1/odbc_install.exe
Could't find Oracle Instant Client in present directory.

在当前目录下找不到“Oracle Instant Client ”?那好就切换到odbc_install.exe所在的目录:

C:/instantclient_11_1>C:/instantclient_11_1/odbc_install.exe
Oracle ODBC Driver is installed successfully.

这样就行了。vbs脚本如下:

Set ws = CreateObject("WScript.Shell") ws.CurrentDirectory = "C:/instantclient_11_1/" ws.Exec("C:/instantclient_11_1/odbc_install.exe") Set ws = Nothing

没想到CurrentDirectory还有如此妙用……