I have an ERP system that allows me to attach VBScript to a button on a customized window. I would like to be able to run this script so that it fires off a SQL Server Agent Job on the server (SQL Server 2008). I've been looking in to this for a couple hours now and the closest thing I could see was a short script which seems to use a depreciated command (SQL.DMO). Here's the code I swiped from the web:
On Error Goto 0: Main()
Sub Main()
Set objSQL = CreateObject("SQLDMO.SQLServer")
' Leave as trusted connection
objSQL.LoginSecure = True
' Change to match the name of your SQL server
objSQL.Connect "Server Name"
Set objJob = objSQL.JobServer
For each job in objJob.Jobs
if instr(1,job.Name,"Job Name") > 0 then
msgbox job.Name
job.Start
msgbox "Job Started"
end if
Next
End Sub
The resulting error is:
Line: 3
Char: 3
Error: ActiveX component can't create object: 'SQLDMO.SQLServer'
Code: 800A01AD
Source: Microsoft VBScript runtime error