Can I execute a batch file on another server using the Script Task or Excute Process Task?

  • Hi,

    I'm trying to figure out how to execute a batch file on different server and have it run there and not from where I'm calling it. Could anyone tell me how I can accomplish this.

    Thanks in advance!

    😀

  • it's kind of difficult, becuase the remote server would need to be able to login to the network in order to get to a UNC path to the batch file...

    declare @command varchar(1000)

    set @command = '"\\myOtherServer\PATH\TO\FILE\mybatch.bat'

    print @command

    exec master..xp_cmdshell @command

    you might need to change the account that is running the service,a nd of course use the surface area configuration to allow xp_commandshell on that remote server as well.

    once you know that the other server can get to the file,

    it depends on what the file is doing to determine whether even that might fail separately due to assumed paths and stuff like that.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • rereading, you might want to look at psexec.exe from sysinternals (now from MS):

    http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx;

    it is an administrative tool that can be used to run executables on other machines, regardless of whether,s ay, SQL Server exists or not.

    that may be what you are looking for.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Great! I'll take a look. Thanks for all your help Lowell!

  • If you want to execute the entire SSIS package on a different server, then just use the sql server agent which supports this I believe. If you only want to execute a portion of the package on a different server, then yeah the last suggestion is an option. I also believe WMI supports execution things remotely but I haven't done that from a package before.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply