JScript runtime error: Permission denied when trying to access ActiveXObject from within a .js file that is invoked via a Stored Proc in SQL Server 2008

I can successfully invoke a .js JavaScript file from within a Stored Proc via xp_cmdshell @command:

SET @Command = @TargetDir + 'ImportDataToAmiBroker.cmd';
EXECUTE xp_cmdshell @Command;

The problem appears to be particular lines of code within the JavaScript fail due to permissions denied.  This .js file works fine from non administrator command prompt within Vista via command such as this:  "cscript ImportDataToAmiBroker.js C:\Users\AmiBroker\data.quiksilver quiksilver.format quiksilver.symbol-info.format C:\Users\TickData\AmiBroker".  It is just failing on this line of code (line 57) when being invoked via stored proc.  Broker.Application refers to a valid app that can be controlled programmatically via OLE:

    var ab = new ActiveXObject("Broker.Application");

Here is the output I receive from SQL Server 2008 Management Studio

NULL
C:\Windows\system32>cd /d C:\Users\TickData\AmiBroker
NULL
C:\Users\TickData\AmiBroker>cscript ImportDataToAmiBroker.js C:\Users\AmiBroker\data.quiksilver quiksilver.format quiksilver.symbol-info.format C:\Users\TickData\AmiBroker
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.
NULL
Arguments:
Ami Database Folder = C:\Users\AmiBroker\data.quiksilver
Quotes Format FileName = quiksilver.format
Symbol Info Format FileName = quiksilver.symbol-info.format
Import Data Folder = C:\Users\TickData\AmiBroker
NULL
C:\Users\TickData\AmiBroker\ImportDataToAmiBroker.js(57, 5) Microsoft JScript runtime error: Permission denied
NULL
NULL

Note, I have "Everyone" group added to C:\Users\TickData\ and C:\Users\AmiBroker\ folders with "Full Control" permissions.  Subsequent child folders'/files' security permissions within these folders are inherited from parent.

Details of SQL Server 2008 Install:

Microsoft SQL Server Management Studio                                    10.0.2531.0
Microsoft Analysis Services Client Tools                                    10.0.1600.22
Microsoft Data Access Components (MDAC)                                    6.0.6002.18005
Microsoft MSXML                                    3.0 5.0 6.0
Microsoft Internet Explorer                                    8.0.6001.18783
Microsoft .NET Framework                                    2.0.50727.4016
Operating System                                    6.0.6002
.cmd file - Command shell script:
 
cd /d C:\Users\TickData\AmiBroker
cscript ImportDataToAmiBroker.js C:\Users\AmiBroker\data.quiksilver quiksilver.format quiksilver.symbol-info.format C:\Users\TickData\AmiBroker
 
.js file - JavaScript snippet:
 
    alert("Arguments:\n" +
            "Ami Database Folder = " + amiDatabaseFolder + "\n" +
            "Quotes Format FileName = " + quotesFormatFileName + "\n" +
            "Symbol Info Format FileName = " + symbolInfoFormatFileName + "\n" +
            "Import Data Folder = " + importDataFolder + "\n"
            );
 
    var ab = new ActiveXObject("Broker.Application");

Open in new window

jdfaganAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jdfaganAuthor Commented:
I'm going to answer my own question after a few hours of Googling around and piecing together different bits that pulled it altogether for me to work.

First, I altered JavaScript as shown in code snippet.

Then, after receiving Event 10016 with this JavaScript code change and calling from Stored Proc, I modified the security so that SQLServer system user has access to my business object model "Broker.Application" via procedures here:

http://support.microsoft.com/kb/899965

That seems to have solved my problem and allowed SQL Server 2008 to properly finish my JavaScript code from within a Stored Proc.

Regards,

JD
    alert("Arguments:\n" +
            "Ami Database Folder = " + amiDatabaseFolder + "\n" +
            "Quotes Format FileName = " + quotesFormatFileName + "\n" +
            "Symbol Info Format FileName = " + symbolInfoFormatFileName + "\n" +
            "Import Data Folder = " + importDataFolder + "\n"
            );
 
    var ds = new ActiveXObject("RDS.DataSpace");
    var ab = ds.CreateObject("Broker.Application", "");

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.