Best way to execute CMD from SQL script
<p>I want to generate some excel reports using vba scripts called from stored procedure. My team got almost the same BI solution, and previously they were using VBA script that opened excel file with macros inside.</p>

<p>Report generation process follows this path:</p>

<p>There's SQL Stored procedure executed from weekly scheduled job, there we call another procedure which is preparing and calculating data, and then we open 
script presented below to run excel.</p>

<p>Here's how this script looks like: </p>

<pre><code>Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("E:\Path\To\Excel.xlsm")
</code></pre>

<p>We call this script in such way:</p>

<pre><code>EXEC master..xp_cmdshell 'C:\WINDOWS\SysWOW64\WSCRIPT.EXE Z:\Path\To\Script.vbs'
</code></pre>

<p>I got some problems with WSCRIPT.EXE, it's hanging when opening reports, and when I was looking for solution I've read much about not using <code>XP_CMDSHELL</code>. And the question is: Is there any way to avoid using <code>XP_CMDSHELL</code> and to not to create report generation path from scratch? I'm a bit in hurry so I don't have time to write new procedures etc. </p>