Solved

PSEXEC not executing correctly through SQL

Posted on 2008-06-11
8
2,333 Views
Last Modified: 2013-12-04
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
Comment
Question by:gnchq
8 Comments
 
LVL 6

Expert Comment

by:Compaq_Engineer
Comment Utility
Does the user that the MS SQL process runs as have permissions to the other server?
0
 

Author Comment

by:gnchq
Comment Utility
Yes.  We are using a domain account that has local admin rights on both the executing and receiving servers.
0
 
LVL 67

Accepted Solution

by:
sirbounty earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:gnchq
Comment Utility
Thanks for helping us out.  I thought it had to by syntax since there are so few issues posted on this subject.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:gnchq
Comment Utility
Awesome.....thanks sirbounty....that was it!  Adding "cmd /c" resolved the issue.
0
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
Glad to help.
Thanx for the notification - and the grade. :^)
0
 

Expert Comment

by:dijjit
Comment Utility
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
 
LVL 67

Expert Comment

by:sirbounty
Comment Utility
You should open a new question.  It's against site policies to piggy back on a closed question...
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
Recently, I read that Microsoft has analysed statistics for their security intelligence report. It revealed: still, the clear majority of windows users do their daily work as administrator. An administrative account is a burden, security-wise. My ar…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now