Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

xp_cmdshell 'dir G:\' don't show all subdir' in directory

Posted on 2003-02-24
5
Medium Priority
?
986 Views
Last Modified: 2011-10-03
I'm trying to validata file existance in a local directory in my computer. I'm executing this procedure through Sql Analizer and this is the exact syntax:
exec xp_cmdshell 'dir G:\'
The output shows only 1 subdirectory but not the others.
When i'm typing the same command through dos, it works fine and shows all the directories.
The operating system is win2k, sql server is standard edition.
Thanks in advance,
Ofer
0
Comment
Question by:ofergold
5 Comments
 
LVL 1

Expert Comment

by:Divaqs
ID: 8011921
Hi ofergold,

What Windows permissions are the SQL server executing under? I would suggest checking.
0
 

Expert Comment

by:mohit108
ID: 8014295
Hi ofergold

U should sheck the windows permission using which u have logged on to the SQL Server.

xp_cmdshell is even more confusing with "Network Mapped Drives" if G: is ur network drive then it won't give u the desired result.

I have tried "xp_cmdshell 'dir/p N:'", it will give u
The system cannot find the path specified.
but the same command from DOS will give u all the directories (dir/p N:)

Thanks
0
 
LVL 1

Accepted Solution

by:
KatanaCS earned 100 total points
ID: 8021222
When using xp_cmdshell, the network account being used is listed in the "Service StartUp Account" of the SQL Server Agent properties.  If this account is different than your account (which is rather normal), then any permissions and network mappings that you have are not carried over into xp_cmdshell.

For example:
  You have "G:\" mapped to "\\Myserver\", which has subdirectories "\DirA", "\DirB", and "\DirC".  It's entirely possible that the SQLAgent account only has permissions to "\DirC" and not the others, or even that it's "G:\" drive is mapped to "\\MyOTHERServer", which only has "\DirC" as a subdirectory.

Regards,
KatanaCS
0
 

Expert Comment

by:CleanupPing
ID: 9276381
ofergold:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

by:ofergold
ID: 9283319
Please remove question
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question