Solved

xp_cmdshell

Posted on 1998-07-27
5
741 Views
Last Modified: 2008-02-01
i am using 6.0 and trying to use the xp_cmdshell procedure.
master..xp_cmdshell 'dir C:\winnt35\system\*.EXE' works.
master..xp_cmdshell 'dir C:\*.EXE' returns the output
Volume in drive C has no label.
Volume Serial Number is C486-8532
(null)
Directory of C:\
(null)
File Not Found

of course there are .exe's in the root directory.

need help.

thanx.
sajal.
0
Comment
Question by:sajalk
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:spiridonov
ID: 1089242
what happend if you put your commands into a bat file and call this bat file from xp_cmdshell. Do you have enought permission to view c:\ ?
0
 

Author Comment

by:sajalk
ID: 1089243
based on your comments, i realized my mistake. i was issuing this command from my workstation, but it is being exctuted on the server machine, and all this while i thought it is yielding results on my machine. yeah! i may not permission to see the C:\.
is there a way to make it look into client machine, probably by using UNC???
look forward to hearing from you again.
thanx much.
sajal.
0
 
LVL 7

Accepted Solution

by:
spiridonov earned 100 total points
ID: 1089244
No this is not possible. Dir doesn't even allow you to choose machine,just drive. Even if it did, what about permissions? Remember, that when you are runnign xp_cmdshell, you are running it not as User, who is logged into SQL server,but as SQL Server or SQLCMDExec account.
0
 

Expert Comment

by:laxmi080598
ID: 1089245
Yes, sajal you can give UNC.  The issues are:

If you have connected to the SQL Server using SA account and then issued the xp_cmdshell "dir \\machine\share", the Sql server tries to access the computer specified in the UNC with the user account assigned to the SQL Server Service.  If the machine is Windows 95 then there are no issues at all.  If the machine to be accessed is NT Server/ NT workstation,  the user account specified for the SQL Server Service should be the same as the account in the NT system to be accessed.  In other words, the usual NT user account issues will come up.  Of course the account in the destination account should have the appropriate access to the share.

If you have connected to the SQL Server as non-sa and if you have enabled Use SQLEXECUTIVECMDEXEC Account for non-sa's thru the Server - Configure - Server Options, then this NT SQLEXECUTIVECMDEXEC account should also be present in the destination NT system to be accessed and have appropriate permissions

Hope this helps.

Thanks & Regards
Dhanalakshmi
---------------------
www.aditi.com
dlaxmi@aditi.com
Microsoft Recommended Support Point



0
 

Author Comment

by:sajalk
ID: 1089246
thanx very much. it did help a lot in clarifying the concepts.
sajal.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Optimizing a query 3 34
Help with SQL Server Stoplist 2 20
What logic to build in order to get a weekly reminder 9 42
SQL Pivot add row totals 2 13
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now