0
votes

I would like to create a SQL job that will close any excel processes opened. I've created a VB Script that works on double-click. I've tried

wscript C:\Apps\DestroyExcel.vbs

using type CmdExec. How can I execute it form SQL to schedule the job to run?

Dim objXL
On Error Resume Next
Set objXL = GetObject(, "Excel.Application")

If Not TypeName(objXL) = "Empty" Then
    objXL.quit
Else
    msgbox "Excel Not Running."
End If
1

1 Answers

0
votes

In SSMS:

  1. Go to SQL Server Agent
  2. Right-click "Jobs" --> New Job
  3. Enter info
  4. In the steps section, click New
  5. For the Type, choose Operating Sytem (CmdExex)
  6. For the command, type: cscript C:\myscript.vbs
  7. Set your schedule
  8. Press OK

I believe that should do it.