xp_cmdshell and psexec

  • hope someone can help me..

    I have a stored procedure which pulls in some records, and if any records are found, should execute an application using xp_cmdshell

    As I dont want these applications to run on my sql server, I'm trying to use psexec by sysinternals to execute them on a remote server.

    so for example.. i have

    EXEC xp_cmdshell 'cmd /c "C:\Program files\Sysinternatls\Pstools\psexec.exe" \\servername C:\Windowsotepad.exe', no_output

    Which runs, but waits..

    notepad.exe never opens on the server specified, and psexec runs on my sql server, and the job never ends until i kill the process.

    Can someone lead me the right way i should be doing this?

    Thanks

    --------------------------

    I long for a job where my databases dont have any pesky users accessing them 🙂

  • the issue you are running into is the account SQL server is running under is not an account that has access to the network. jobs (and xp_cmdshell, or anything that access objects outside of the SQL server database itself) run under the security context of a specific account, and not the person who created the job nor who is logged in, , or even who is running it manually.

    The username/password used to run the service must be able to login/browse to the network(as well as having WRITE permissions to the \\server share)

    you'll want to go to Control Panel >>Administrative Tools Services>> The specific SQL Server Instance(might be more than one)

    You'll want to change the screen below to run under a login you create that would have access to the machine in question...so if you create a new user named SQLAdmin, and that user has access, that user could be used to start up the account and jobs run under that context would perform as expected.

    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!

  • I changed the SQL Server and sql agent to run under a domain account that has administrative rights to the machine im trying to run the exe's on.. no change :

    --------------------------

    I long for a job where my databases dont have any pesky users accessing them 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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