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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Error while running xp_cmdshell

Author  Topic 

Chris Allison
Starting Member

2 Posts

Posted - 2005-05-03 : 13:21:15
I am getting the following error when running a command in Query
Analyzer.

Msg 50001, Level 1, State 50001
xpsql.cpp: Error 5 from CreateProcess on line 675

Here is the command that I am running that generates this error
message:

xp_cmdshell "@ECHO test message > c:\temp\newtemp.txt"

The command inside the xp_cmdshell command runs successfully from a
Windows command prompt. Simpler commands also fail with the same error
message. For example:

xp_cmdshell 'dir'

Can anyone suggest a solution to this problem? I assume this problem is
due to a permissions/security issue. I have given Everyone Full Control
over c:\temp.

Windows 2000
SQL Server 2000

Thanks for any help.

X002548
Not Just a Number

15586 Posts

Posted - 2005-05-03 : 13:26:55
I do this in sprocs like


SET @var = RTrim(Convert(Char(20),@Log_Id)) + '|U|'+RTrim(Convert(char(50),GetDate(),109))+'|Starting Quarterly Load Process'
SET @cmd = 'echo ' + '"|' + @var + '|"' + ' > d:\Data\Tax\log_out.txt'
SET @Command_string = 'EXEC master..xp_cmdshell ''' + @cmd + ''', NO_OUTPUT'

Exec(@Command_String)



Or from QA as

EXEC master..xp_cmdshell 'Dir C:\*.*'




Brett

8-)
Go to Top of Page

Chris Allison
Starting Member

2 Posts

Posted - 2005-05-03 : 14:10:29
Using the following as you suggested results in the same error message for me:

EXEC master..xp_cmdshell 'Dir C:\*.*'

Msg 50001, Level 1, State 50001
xpsql.cpp: Error 5 from CreateProcess on line 675

Thanks though.

Anyone else have any suggestions?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-05-03 : 14:45:11
You got the latest service pack?

http://www.novicksoftware.com/Articles/SQL-Server-2000-SP3-and-xp_cmdshell-Woes.htm



Brett

8-)
Go to Top of Page
   

- Advertisement -