Link to home
Start Free TrialLog in
Avatar of chrislindsay
chrislindsayFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Using a hta file with MSSQL agent to schedule a script job

Hi Experts,
I am trying to execute a hta file using
EXEC master..xp_CMDShell "C:\Users\superuser\Desktop\queue.hta" in SQL server agent.

The hta file contains :
<HTML><HEAD></HEAD>
<FRAMESET ROWS="100%">      <FRAME NAME="doit" SRC="https://abc.com/queue" onload="window.close();">
</FRAMESET>
</HTML>

The file executes when initiated manually from the desktop but I cannot get it to work inside an SQL job.  
I am using a T-SQL scrip inside the job.  THe job runs but nothing happens...
Im not sure this a security issue as the job agent is running as an windows adminstrator.
I have tried using CMDEXEC running as an SQL service accont agent but I think this is a securtiy issue and can't complete the job..
Any tips would be helpful thanks...
Avatar of chaau
chaau
Flag of Australia image

The hta file is not an executable. It is a script that needs to be opened by an executable. All scripts are executed by some sort of a binary file, e.g when you click on a vbs file the actual command is:
wscript.exe c:\Name.vbs

Open in new window

The same rule applies to the hta file. An HTA is executed using the program mshta.exe, so the correct syntax will be:
EXEC master..xp_CMDShell "mshta.exe C:\Users\superuser\Desktop\queue.hta"

Open in new window

Avatar of chrislindsay

ASKER

Hi Chaau,
When I run the query in a Query window, the query just hangs and necer finishes.  
This also happens when you place the query in an sql job and exectue it.
The script runs from the desk top so I think it is a security issue but not sure how to fix it?

Thansk Chris
ASKER CERTIFIED SOLUTION
Avatar of chaau
chaau
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the delay.  It was a permissions thing thanks works now