Solved

xp_cmdshell

Posted on 1998-07-27
5
754 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 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

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

615 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