Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Trouble with xp_cmdshell

Author  Topic 

Razmo
Starting Member

5 Posts

Posted - 2009-07-28 : 11:27:32
This works:

SET @Cmd = 'dir C:\SomeDirectory\*.* >> C:\SomeOtherDirectory\Dir.Txt'
EXEC master..xp_cmdshell @Cmd

This does not:

SET @Cmd = 'dir SomeDriveLetter:\SomeDirectory\*.* >> C:\SomeOtherDirectory\Dir.Txt'
EXEC master..xp_cmdshell @Cmd

But yet when 'ran' in a cmd session, example 2 works.

I'm running Windows XP Pro on a Novell network. Am I doing something wrong or is xp_cmdshell incompatible with the OS I'm running?

X002548
Not Just a Number

15586 Posts

Posted - 2009-07-28 : 12:11:24
when you run in cmd it's tyour mappings, not the servers



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

Razmo
Starting Member

5 Posts

Posted - 2009-07-28 : 12:46:53
Thanks for your reply Brett. In this case the server (Express) is on my PC, so in theory should recognize the same drive letters, correct?
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-07-28 : 13:12:54
mapped drives are user specific. xp_cmdshell runs under a different account.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -