I have created a script that automates the launching of an application based upon a value in the registry. For some reason, it is not connecting to the database to read what application it's supposed to launch. I have combed over this script and can't figure out what the issue is. Please help.
At this point any help would be appreciated.
Thanks
Code:
' VBScript File for synchronizing error proofing applications and launching the correct EP application on station start up.
'Error handling
On error resume next
'Create variables
Dim objShell 'WScript Shell object
Dim strReg1 'StationName
Dim objConn 'Database Connection
Dim strSQL 'SQL Command String
Dim objRec 'Recordset
Dim strConn 'Connection String
Dim strEPApp 'Error Proofing Application String
Dim appExec 'SyncToy executable variable
Dim appExec2 'EP executable variable
'Decalare and open connection string and recordset and set objects
Set objConn = CreateObject("ADODB.Connection")
strConn="Provider=SQLOLEDB; Data Source=XXXXXX;Trusted_Connection=Yes;Database=XXX;UID=XXX; PWD=XXX;"
Set objRec = CreateObject("ADODB.Recordset")
Set objShell = WScript.CreateObject("Wscript.Shell")
'Declare File and Reg variables
strReg1 = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Error Proofing Station\Properties\StationName"
'Declare variable for database records by reading registry values into recordset.
Dim rec1
rec1 = objShell.RegRead(strReg1)
If rec1 = "" then
strReg1 = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Prepick Error Proofing Station\Properties\StationName"
rec1 = objShell.RegRead(strReg1)
End If
wscript.echo rec1
'Declare SQL Statements
strSQL = "Select * from EPApps where StaName ='" & rec1 &"'"
wscript.echo strSQL
objRec.Open strSQL, strConn
strEPApp = objRec.fields(2).value
'Launch Synctoy App
Dim WShell
Set WShell = WScript.CreateObject("WScript.Shell")
Set appExec = WShell.Exec("C:\SyncToy\SyncToy.exe -R")
Wscript.Sleep 5000
Set appExec2 = WShell.Exec("C:\Program Files\OnlineErrorProofing\" & strEPApp )
Thanks
Comment