472,803 Members | 889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,803 software developers and data experts.

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

Me
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....
Jul 22 '05 #1
3 7954
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" <he****@lycos.com> wrote in message
news:2d**************************@posting.google.c om...
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....

Jul 22 '05 #2
Me
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message news:<u9**************@TK2MSFTNGP14.phx.gbl>...
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.


but, (as I mentioned) I made sure that the Query analyzer connection uses
the same SQL login/pass as the ASP client connection....

what other login is there?
Jul 22 '05 #3
Get Filemon:
http://www.sysinternals.com/ntw2k/source/filemon.shtml

If you run this while trying with each method, you should see the
difference.

--
http://www.aspfaq.com/
(Reverse address to reply.)


"Me" <he****@lycos.com> wrote in message
news:2d**************************@posting.google.c om...
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message

news:<u9**************@TK2MSFTNGP14.phx.gbl>...
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.


but, (as I mentioned) I made sure that the Query analyzer connection uses
the same SQL login/pass as the ASP client connection....

what other login is there?

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bego?a | last post by:
Is it possible to access a file (for example, to write in a text file) with transact-sql?. I've create a stored procedure and I'd like to write in a log file some traces depends on the result of...
10
by: Bing Du | last post by:
Greetings, Our former SQL Server 2000 DBA backed up everything in a single disk file. By everything I mean, full backup, differential backup and transaction logs. See below for details of how...
4
by: Kartik | last post by:
Hi, I have an ASP.NET application using VB.NET.I am sending a DOS command to a machine on the network to print a file. This is achieved using xp_cmdshell Dim str As String = "xp_cmdshell...
10
by: bdwgarth | last post by:
I have created a functioning DTS package inside Enterprise Manager and now I want to be able to execute it outside of EM. The package imports data from an SQL dbase to a Visual FoxPro dbase. I...
1
by: Michael McGarrigle | last post by:
I would like to send the contents of a file using xp_sendmail however I do not want the file contents to be an attachment. I have no problem sending the file as an attachement. Can anybody give me...
3
by: phantom | last post by:
Greetings, I have a sp that dumps text into a textfile but I am having trouble creating the textfile. EXEC master.dbo.xp_cmdShell '\\servername\d$\The File\sub\filename.dat' The directory...
6
by: mcolson | last post by:
Is it possible to use sql to execute a batch file? I would like to execute the following "C:\BTW\bartend.exe /f=C:\BTW\Toolbox\Formats \carnum.btw /p", 6 Thanks, Matt
1
by: funga | last post by:
Once the procedure is executed the database transaction log would be backed up and zipped with a blank text file which has the the current date DD/MM/yyyy as the text file name exec ('exec...
3
by: tprizler | last post by:
Hi, I am trying to use Net::SSH::Expect. Basically I had success login into a remote server using this module. The thing is i think i have a syntax problem... I am logging into a remote...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.