我需要編寫一個控制檯應用程序,該應用程序返回可以通過xp_cmdshell捕獲的返回代碼。XP_CMDSHELL如何捕獲返回值?
我開始用C#代碼如下,
class Program
{
static int Main(string[] args)
{
//make sure the correct number of arguments are being passed.
if (args.Length !=5)
{
Console.WriteLine("not thr right number of args. \nUsage SFTPUploadFile <host> <port> <username> <password> <localFilePath>");
return 1;
}
return 0;
}
}
的XP_cmdhsell我使用一些代碼,我發現
declare @rc int
create table #output (id int identity(1,1), output nvarchar(255) null)
insert #output (output) exec @rc = master..xp_cmdshell 'd:\FILENAME PARA1 PARA2 PARA3 PARA4 PARA5'
select * from #output where output is not null order by id
drop table #output
,但是當我運行xp_cmdshell的,我只是得到空。我不應該得到1或0?
感謝
您可能應該將您的調用添加到'xp_cmdshell'以及如何驗證其值。我本地的 –