Using psexec.exe in jenkins, handle is invalid

耗尽温柔 提交于 2019-12-05 07:47:25

Thanks to all your help, especially Technext, I have a solution.

I needed run "services.msc", find "Jenkins", right click on it, and go to "Properties". Once the properties windows appeared, I had to click the "Stop" button to stop Jenkins, open the "Log On" tab, enter in my username and password (the username I used when running through command prompt), and start Jenkins again. That got rid of the "handle is invalid" message in Jenkins.

Update: A better solution was to go onto the system I was using psexec.exe to get onto, go to Control Panel > User Accounts > Give other users access to this computer. Click on "Add..." and type in the username and domain Jenkins uses to run its commands (to find this, open your Jenkins in a browser window, go to Manage Jenkins > System Information and look for USERNAME and USERDOMAIN under Environment Variables). Make sure you give it Administrator rights. Then click ok. Now psexec.exe shouldn't have the "handle is invalid" issue.

Gurr3

Sorry, I don't have enough reputation for comments, but is the single \ a typo? Since

The handle is invalid.

probably means that the computer address is invalid. Try

 psexec.exe \\ABCDEFG -u "DOMAIN\username" -p "password" "C:\test.bat"

Notice the two backslashes to access a locally mapped computer.

otherwise if that does not work i recommend the @ tag

psexec.exe @servername.txt -u "DOMAIN\username" -p "password" "C:\test.bat"

where @servername.txt is a textfile containing only the servernames, one per line. The file parameter handles the formatting of \

ex servername.txt

ABCDEFG
COMPUTER2

EDIT: also found after some quick googling that it can be related to windows security.

Check out that a simple restart of the remote machine doesn't solve the problem. Also, adding parameters -h and -accepteula may help. Modified command:

psexec.exe \\ABCDEFG -u "DOMAIN\username" -p "password" -h -accepteula "C:\test.bat"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!