3

I'm trying to run a batch script on multiple servers using a vbscript that's from another server. I'm using psexec on my local machine to run this batch script.

This is the script I'm running:(This is server 2003)

    psexec -s -accepteula \\SERVERNAME -u userName -p DOMAIN\password cmd.exe
    /c cscript \\otherServerName\c$\folder\script.vbs

I'm getting this error:

    Error establishing communication with PsExec service on SERVERNAME
    The system cannot find the file specified.

I'm running this script on server 2003, 2008, and 2012. When I try to run the script on a server 2008 server it gives me an "access denied" error despite the fact that I'm using administrator credentials.

Alex Kulinkovich
  • 4,408
  • 15
  • 46
  • 50
giacmeister
  • 35
  • 1
  • 2
  • 7
  • Are you logged on to \\otherServerName ? Does it work with a local copy of the .vbs? – Alex K. Jul 21 '14 at 15:27
  • I logged on to the \\otherServerName and it works just fine. I also logged in to \\SERVERNAME and ran the script that's located on \\otherServerName and it worked fine. So I know that it can find the vbscript just fine from another server. @AlexK. – giacmeister Jul 21 '14 at 15:32
  • I would try and log onto the server using cmd and see if you can get more information from there. `psexec.exe \\SERVERNAME -u userName -p DOMAIN\password cmd.exe -accepteula` It is possible that the error is not refering to your script. Maybe cmd or cscript is not part of the $env:Path of that server. – Matt Jul 21 '14 at 19:03
  • Looks like you are trying to copy files from a file server and execute on several machines?? If you do not want to use psexec there is another simple way out. – Waman Jul 22 '14 at 11:25
  • @Waman You are correct, I'm using a script from the file server and executing it on many servers, what would be the other way? – giacmeister Jul 22 '14 at 14:54
  • One more question before I could tel you other way, are you triggering this from a single machine which will remotely download and execute that file on each of the servers? if so which is the base machine where you trigger from it is windows or Linux? – Waman Jul 23 '14 at 04:12
  • @Waman I am using my local machine to trigger a script from another single machine which will execute the file on each server. I do not have it download to each server, just execute. The base machine is windows. If that is not clear then let me know so I can reword it. – giacmeister Jul 28 '14 at 15:33
  • If your base machine is a non-windows machine you can easily trigger it in single base machine which will execute on multiple target machines (both windows n non-windows). This can be done using expect script.. I can provide you a sample in case you are planning for Linux base machine – Waman Jul 30 '14 at 09:50

2 Answers2

1

Maybe you just copied the command incorrectly, but DOMAIN\ should precede the userName, not the password.

I am also having the same error though, with the very simple command

psexec \\SERVER cmd

I've found it seems to be a problem with PsTools 2.1; I can execute this command with PsTools 1.98 and it works fine. You might want to try using a different version of PsTools.

adipy
  • 166
  • 3
1

I was having he same issue and fully qualifying the server name fixed it for me:

psexec -s -accepteula \\SERVERNAME.MYDOMAIN.COM -u DOMAIN\userName -p password cmd.exe
/c cscript \\otherServerName\c$\folder\script.vbs
JayR
  • 11
  • 1