Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

xp_cmdshell

Posted on 1998-07-27
5
Medium Priority
?
756 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

722 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