Link to home
Create AccountLog in
Avatar of gnchq
gnchqFlag for United States of America

asked on

PSEXEC not executing correctly through SQL

Trying to run the psexec command below through SQL cmdshell.  The command is running from one server and executing on another.  If we run the command from outside of SQL, it works.  Running in SQL it gets as far as starting psexec (verified through Windows task manager) and just hangs.

master..xp_cmdshell 'd:\pstools\psexec \\servername -u username -p password -d d:\dbascripts\2_Stoplawson_tst.cmd'

master..xp_cmdshell 'd:\pstools\psexec \\servername -u username -p password -d d:\dbascripts\2_Stoplawson_tst.cmd'

Open in new window

Avatar of Compaq_Engineer
Compaq_Engineer
Flag of United Kingdom of Great Britain and Northern Ireland image

Does the user that the MS SQL process runs as have permissions to the other server?
Avatar of gnchq

ASKER

Yes.  We are using a domain account that has local admin rights on both the executing and receiving servers.
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of gnchq

ASKER

Thanks for helping us out.  I thought it had to by syntax since there are so few issues posted on this subject.
Avatar of gnchq

ASKER

Awesome.....thanks sirbounty....that was it!  Adding "cmd /c" resolved the issue.
Glad to help.
Thanx for the notification - and the grade. :^)
Avatar of dijjit
dijjit

So I have tried the above but my script still runs forever.

Curiously, if I ask it to run a process that is going to error (e.g. error code 1 or above) - it returns fine. However, if things are returning with error code 0 (e.g. sucess) - then they never return within SQL.

I have checked the user details and can confirm there is no issues there. Urgently need to get this working!! Help!
You should open a new question.  It's against site policies to piggy back on a closed question...