Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Security / October 2005

Tip: Looking for answers? Try searching our database.

Using DOS commands via xp_cmdshell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy - 06 Oct 2005 14:19 GMT
Hi

I'm trying to use the DOS copy command to copy a file from the servers local
drive to a mapped network drive (to a share on a different domain).  When I
run the command in DOS, it works just fine, but when running the same
command using xp_cmdshell I get an error: "The system cannot find the drive
specified".

Can anyone advise how I can get this to work?

Thanks
Andy
Mike Epprecht (SQL MVP) - 06 Oct 2005 16:30 GMT
Hi

1. Forget about mapped drives, use UNC paths.
2. Make sure your SQL Server is running under a domain account that has
permissions on the destination server. In your case, you need a trust
relationship between the domains.

Regards
--------------------------------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

> Hi
>
[quoted text clipped - 8 lines]
> Thanks
> Andy
Andy - 06 Oct 2005 16:44 GMT
Thanks for the reply - got it sorted thanks.

I used 'use net' via xp_cmdshell to map the drive with the correct username
& password, then do (i.e. copy) what I need to do, then unmap the drive, all
using xp_cmdshell.

Cheers
Andy

> Hi
>
[quoted text clipped - 26 lines]
>> Thanks
>> Andy
Andrew J. Kelly - 06 Oct 2005 17:48 GMT
As Mike stated you should get in the habit of not using mapped drives even
though it may have worked for you this time.  That way you do not have to
deal with mapping and such and overall your code is less likely to break.

Signature

Andrew J. Kelly  SQL MVP

> Thanks for the reply - got it sorted thanks.
>
[quoted text clipped - 35 lines]
>>> Thanks
>>> Andy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.