Re: Trying to Execute a file using exec master.dbo.xp_cmdshell, from ASP

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 11/30/04


Date: Tue, 30 Nov 2004 09:35:16 -0500

You're running it in Query Analyzer as YOU, however the ASP page is likely
running in the context of IUSR, which has a different set of security
credentials.

-- 
http://www.aspfaq.com/
(Reverse address to reply.)
"Me" <heruti@lycos.com> wrote in message
news:2d4c3262.0411300522.644c9b65@posting.google.com...
> hi, I have this file I need to execute from an ASP client. since we
> have installed it on the SQL Database server machine, I thought I
> could run it
> like this:
>
>
> Set Cn = CreateObject("ADODB.Connection")
>
> Cn.CursorLocation = adUseClient
> Cn.ConnectionTimeout = 0
> Cn.Open sConnString
> Cn.Errors.Clear
>
> If Not Cn.State = adStateOpen Then
> m_sErrorData = "No active connection"
> Exit Function
> End If
>
> Set Rs = CreateObject("ADODB.Recordset")
> set Rs = Cn.Execute("exec master.dbo.xp_cmdshell
> 'C:\serverdir\test.exe usr/ProfileXXX YYY"
>
>
> But, when I try this, it only works if I remove the parameter
> usr/ProfileXXX YYY from the command.  If I keep it, it just hangs on
> the .execute command.
>
> Strangely enough, If I try to run the same command (with the
> parameter) on
> the SQL Query analyzer (with the same user connection that the ASP
> client uses)
> it works...  ( I know it works because execution proceeds to the next
> line after Cn.Execute, and I get back a recordset in Rs with line
> results from the executable (see below).
>
>
> I have also tried to run the executable with the exec
> master.dbo.xp_cmdshell   command from within a stored procedure (and
> then execute it from ASP)
> same results. Runs only from Query analyzer...
>
> By the way I am not doing this on ther server but on a remote machine.
> Shouldn't matter though, because with Query analuyzer it does work.
>
> I think it can only have something to do with the inclusion of the
> parameter and its effects.
>
> if the executable is run with it in query analyzer, the result in the
> output grid is:
>
> (one grid result line for each text line)
>
> Starting Link-Run ...
>  0 Lines Processed out of 0
> 0 Elements Created with 0 Errors
> NULL
>
> (this result is ok)
>
> but if I run it without the parameter:
>
>
> Usage: 'C:\serverdir\test.exe User[/Profile] Code
> NULL
>
> I can't figure it out.
>
> Thanks for any help....


Relevant Pages

  • Re: using "Wscript.Shell" in asp
    ... Enable authentication and disable anonymous access to the ASP page ... I want to use the "dtsrun" command in an ASP page. ... When i execute the page, i get no error, but the dtsrun does not seem ...
    (microsoft.public.scripting.wsh)
  • Re: xp_sendmail hangs
    ... Can you execute the ... appropriate command via Query Analyzer? ... > We have jobs set up that send notifications when they ...
    (microsoft.public.sqlserver.tools)
  • Trying to Execute a file using exec master.dbo.xp_cmdshell, from ASP
    ... I have this file I need to execute from an ASP client. ... usr/ProfileXXX YYY from the command. ... the SQL Query analyzer (with the same user connection that the ASP ...
    (microsoft.public.inetserver.asp.general)
  • Trying to Execute a file using exec master.dbo.xp_cmdshell
    ... I have this file I need to execute from an ASP client. ... usr/ProfileXXX YYY from the command. ... the SQL Query analyzer (with the same user connection that the ASP ...
    (microsoft.public.sqlserver.programming)
  • VBA Equivalent of ASP Execute Command
    ... Is there a VBA equivalent of ASP's 'Execute' command. ... a command to dynamically declare variables at run-time. ... Here's a sample of ASP 'Execute' code. ...
    (microsoft.public.excel.programming)