473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 7992
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.