• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2487
  • Last Modified:

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

0
gnchq
Asked:
gnchq
1 Solution
 
Compaq_EngineerCommented:
Does the user that the MS SQL process runs as have permissions to the other server?
0
 
gnchqAuthor Commented:
Yes.  We are using a domain account that has local admin rights on both the executing and receiving servers.
0
 
sirbountyCommented:
Try passing it through the command interpreter...
master..xp_cmdshell 'cmd /c d:\pstools\psexec \\servername -u username -p password -d d:\dbascripts\2_Stoplawson_tst.cmd'

Open in new window

0
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
gnchqAuthor Commented:
Thanks for helping us out.  I thought it had to by syntax since there are so few issues posted on this subject.
0
 
gnchqAuthor Commented:
Awesome.....thanks sirbounty....that was it!  Adding "cmd /c" resolved the issue.
0
 
sirbountyCommented:
Glad to help.
Thanx for the notification - and the grade. :^)
0
 
dijjitCommented:
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!
0
 
sirbountyCommented:
You should open a new question.  It's against site policies to piggy back on a closed question...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now