xp_cmdshell issue

Results 1 to 2 of 2

Thread: xp_cmdshell issue

  1. #1
    Join Date
    Dec 1969

    Default xp_cmdshell issue

    &nbsp;<BR>Hi .<BR><BR>I have encountered a problem with using master.dbo.xp_cmdshell.<BR>when i run the below commands in dos on my local machine ...all works fine (i.e .. i create a temp mapped g: drive which is on a remote machine called 065.... and then i copy a file from my D: drive into the newly creqted G: drive.. )<BR><BR>However i need to automate this process so i have put the following into a stored proc.... but nothing seems to happen... i aslo tried putting teh code into a dts package but this too has issues....<BR><BR>i know that the issue is prob a permissions issue....and that is why it runs in dos because dos is encapsulated by my windows network account and password ... if you have any idea how i coul get around this then your help would be very useful<BR><BR><BR>declare @DTS_string varchar(200)<BR>Declare @DTS_string2 varchar(200)<BR>Select @DTS_string = &#039;net use G: \065shareDrv$ /persistent:no&#039;<BR>Select @DTS_string2 = &#039;copy D:EvUnitertIndexQACI_trait.xls G:&#039;<BR>exec master.dbo.xp_cmdshell @DTS_string<BR>exec master.dbo.xp_cmdshell @DTS_string2

  2. #2
    Join Date
    Dec 1969

    Default RE: xp_cmdshell issue

    First a question....Why are you trying to automate this from within SQL Server? Do you have a case for it, or did you just pick SQL Server because you can? <BR><BR>I&#039;d suggest turning this into a batch file, or a VBS script and scheduling it through Windows if you need to fire it on a recurring basis, and you won&#039;t be opening up all of the serious, serious security issues associated with xp_cmdshell.<BR><BR>That said, if you *do* have a case for doing this using xp_cmdshell, you&#039;ll need to grant execute permissions on xp_cmdshell to the account that you&#039;re using to log into SQL Server with. <BR><BR>Something like ths:<BR>[code language="T-SQL"]<BR>USE MASTER<BR>GO<BR>GRANT EXECUTE ON dbo.xp_cmdshell TO YourSqlUser<BR>GO<BR>[/code]<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts