By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,035 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,035 IT Pros & Developers. It's quick & easy.

VB Script - Unable to launch apps

BezerkRogue
P: 68
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:

Expand|Select|Wrap|Line Numbers
  1. ' VBScript File for synchronizing error proofing applications and launching the correct EP application on station start up.
  2.  
  3. 'Error handling
  4. On error resume next
  5.  
  6. 'Create variables
  7.  
  8. Dim objShell 'WScript Shell object
  9. Dim strReg1  'StationName
  10. Dim objConn  'Database Connection
  11. Dim strSQL   'SQL Command String
  12. Dim objRec   'Recordset
  13. Dim strConn     'Connection String
  14.  
  15. 'Decalare and open connection string and recordset and set objects
  16. Set objConn = CreateObject("ADODB.Connection")
  17. strConn="Provider=SQLOLEDB; Data Source=SomeServer;" & _
  18.         "Trusted_Connection=Yes;Database=SomeDB;" & _
  19.              "UID=SomeUID; PWD=XXXXXX;"
  20.  
  21. Set objRec = CreateObject("ADODB.Recordset")
  22. Set objRec1 = CreateObject("ADODB.Recordset")
  23. Set objShell = WScript.CreateObject("Wscript.Shell")
  24.  
  25. 'Declare File and Reg variables
  26.  
  27. strReg1 = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Error Proofing Station\Properties\StationName"
  28.  
  29. 'Declare variable for database records by reading registry values into recordset.
  30. Dim rec1
  31.  
  32. rec1 = objShell.RegRead(strReg1)
  33.  
  34. If rec1 = "" then
  35.     strReg1 = "HKEY_CURRENT_USER\Software\VB and VBA Program Settings\Prepick Error Proofing Station\Properties\StationName"
  36.     rec1 = objShell.RegRead(strReg1)
  37. End If
  38.  
  39. 'Declare SQL Statements
  40. strSQL = "Select * from EPApps where StaName ='" & rec1 &"'"
  41. objRec.Open strSQL, strConn
  42.  
  43. 'Launch Synctoy App
  44. Dim WShell
  45. Set WShell = WScript.CreateObject("WScript.Shell")
  46. WShell.Run "C:\SyncToy\SyncToy.exe -R"
  47. Wscript.Sleep 5000
  48. WShell.Run "C:\Program Files\OnlineErrorProofing\" & objRec.fields(2).value
  49.  
Jul 10 '08 #1
Share this Question
Share on Google+
1 Reply


BezerkRogue
P: 68
I figured it out. Switched to the EXEC method and it runs perfectly.
Jul 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.