Sql-server – Run an exe file that exists on a different server from a SQL Server Job

jobssql serversql-server-2008-r2

We have an .exe file on a server, say Server1 which should be run from a SQL Server job that exists on a different server, e.g.: Server2. How can it be done?

I know if it's a local file, I can use xp_cmdshell in the Job step and run the .exe file, but in our case, this file exists on a different server. If it's doable, what security permissions should be set up to achieve it?

Best Answer

Xp_cmdshell would work fine - just access the file using the UNC path (\server1\share\file.exe). As the other person mentioned, make sure you have proper permissions for you sql agent service account to access the file.

If, instead, you actually want to run the file on the remote server, you can use a tool called PSEXEC that will run am exe on another server. This isn't common, but it sounds like it might be what you're looking for. You can get that tool here:

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