I have created a VB Script to synchronize software versions and then launch an application on the system it is run against. The script runs and generates no errors but will not launch the second application. The application name is dynamic and is selected from table. WScript.Echo verifies that it is calling the correct application and the path statement is correct. Also the application does reside where I am calling it from.
The code calling the second application generates no errors. I am at a loss. Here is the script:
The code calling the second application generates no errors. I am at a loss. Here is the script:
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
'Decalare and open connection string and recordset and set objects
Set objConn = CreateObject("ADODB.Connection")
strConn="Provider=SQLOLEDB; Data Source=SomeServer;" & _
"Trusted_Connection=Yes;Database=SomeDB;" & _
"UID=SomeUID; PWD=XXXXXX;"
Set objRec = CreateObject("ADODB.Recordset")
Set objRec1 = 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
'Declare SQL Statements
strSQL = "Select * from EPApps where StaName ='" & rec1 &"'"
objRec.Open strSQL, strConn
'Launch Synctoy App
Dim WShell
Set WShell = WScript.CreateObject("WScript.Shell")
WShell.Run "C:\SyncToy\SyncToy.exe -R"
Wscript.Sleep 5000
WShell.Run "C:\Program Files\OnlineErrorProofing\" & objRec.fields(2).value
Comment