Solved

xp_cmdshell

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

11 Experts available now in Live!

Get 1:1 Help Now