473,503 Members | 1,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Command works in DOS but not in xp_cmdshell

Can anyone give clues as to why the same copy command works in
DOS and not in xp_command shell.I am an admin in both servers and
in the database.

The results indicate one file is copied but no file is found
at destination.

Your input is appreciated

Vincento


copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"

works just fine but

use
master
exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"'
Jul 20 '05 #1
3 8388
nib

What is the user context that the script is running in? Usually it is
system (I think), which isn't going to have access rights to corp156.

Zach

Vincento Harris wrote:
Can anyone give clues as to why the same copy command works in
DOS and not in xp_command shell.I am an admin in both servers and
in the database.

The results indicate one file is copied but no file is found
at destination.

Your input is appreciated

Vincento


copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"

works just fine but

use
master
exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"'

Jul 20 '05 #2

"Vincento Harris" <wu*****@yahoo.com> wrote in message
news:2f**************************@posting.google.c om...
Can anyone give clues as to why the same copy command works in
DOS and not in xp_command shell.I am an admin in both servers and
in the database.

The results indicate one file is copied but no file is found
at destination.

Your input is appreciated

Vincento


copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"

works just fine but

use
master
exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"'


I tried this out, and it worked fine for me (I didn't test using a share,
but I did test using folder names with spaces) - was the result you saw "1
file(s) copied"? Or did you run this as a scheduled job perhaps? When a
sysadmin executes xp_cmdshell, it runs as the MSSQL service account, so you
might want to check that account's permissions also.

Simon
Jul 20 '05 #3
"Simon Hayes" <sq*@hayes.ch> wrote in message news:<41**********@news.bluewin.ch>...
"Vincento Harris" <wu*****@yahoo.com> wrote in message
news:2f**************************@posting.google.c om...
Can anyone give clues as to why the same copy command works in
DOS and not in xp_command shell.I am an admin in both servers and
in the database.

The results indicate one file is copied but no file is found
at destination.

Your input is appreciated

Vincento


copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"

works just fine but

use
master
exec xp_cmdshell 'copy "D:\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\back1.
txt" "\\corp156\d$\Program Files\Microsoft SQL
Server\MSSQL\BACKUP\QMISDEV\"'


I tried this out, and it worked fine for me (I didn't test using a share,
but I did test using folder names with spaces) - was the result you saw "1
file(s) copied"? Or did you run this as a scheduled job perhaps? When a
sysadmin executes xp_cmdshell, it runs as the MSSQL service account, so you
might want to check that account's permissions also.

Simon

I appreciate your answers guys .It does work on the same server for me too.
When the mssqlserver was under local admin account
The result was " Access denied"

When I made this account part of the admin account
The result was "1 file copied" and it actually works

So my problem was not making mssqlservice account an admin
of the //server (//corp156)

Thanks again for the exceptional contributions I always get from
this group

Vincento
Jul 20 '05 #4

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

Similar topics

3
7641
by: Yvonne | last post by:
Would like to implement Blat on SQL Server 2000. I'm looking for example syntax for setting up BLAT with xp_cmdshell. TIA
1
33187
by: Dan Bart | last post by:
I need to execute xp_cmdshell in a trigger and pass a command line parameter to the .exe program i.e. I have a .exe program c:\program files\savedata.exe In the trigger I have a parameter @Id...
4
8072
by: Joel Thornton | last post by:
Whenever something is inserted to a given table, I want to run some shell commands using xp_cmdshell. Would it be a bad idea to put this xp_cmdshell in the INSERT trigger of this table? I...
1
4242
by: Steve Duke | last post by:
Here is the block of the sproc that I?ve created. All lines execute fine except for the ?exec master..xp_cmdshell @reboottc?. In order to make this work from the query analyzer I had to set the...
1
5411
by: Micah Gentry | last post by:
Is there any way to allow a user to use the xp_cmdshell extended stored procedure without giving that user execute permissions to xp_cmdshell in SQL server 6.5? Let me clarify. Lets say I (as the...
2
18689
by: dynoweb | last post by:
I have several *.sql files with schema/data changes to be applied to our current database. Is there a way to create a TSQL script that could be run from the SQL Query Analyzer that would...
4
9872
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...
3
3820
by: Michael C# | last post by:
Hi all, I'm sending a command via SqlClient, and it returns two result sets. I can successfully read the first result set, but how can I access the second result set? Here's an example of my...
0
1077
by: simon | last post by:
I have dataGrid on my page with edit button. When user click edit button and change some value and after that click update button, the following code is executed: oCmd = New...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.