Link to home
Start Free TrialLog in
Avatar of sajalk
sajalk

asked on

xp_cmdshell

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.
Avatar of Victor Spiridonov
Victor Spiridonov
Flag of Russian Federation image

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:\ ?
Avatar of sajalk
sajalk

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Victor Spiridonov
Victor Spiridonov
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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



Avatar of sajalk

ASKER

thanx very much. it did help a lot in clarifying the concepts.
sajal.