Powershell – execute a batch file on remote machine

batch-filepowershellpsexec

I'm trying to execute a batch file(shutdown.bat and startup.bat of tomcat 7) on a remote machine(Windows server 2008) using PSTools but didn't got any luck till now.

Below are the steps I used

c:\>psexec \\129.12.3.1 -u Admin -p admin90 C:\>Hyp\tom7_50080\bin\shutdown.bat 

and on my cmd i got

PsExec v2.0 – Execute processes remotely
Copyright (C) 2001-2013 Mark Russinovich
Sysinternals – www.sysinternals.com

PsExec could not start cmd on 129.12.3.1:
There are currently no logon servers available to service the logon request.

Can anyone help with the above output and with the batch file for executing the shutdown and startup batch file on remote machine.

Is PS Tools only option to execute any service/batch file on remote machine or we could use any other utility provided by MS.

Best Answer

  • In you example, @David Candy pointed out even you had the connection go thru, it would not work as you have 'c:>hyp\' instead of C:\hyp\tom7_*

  • You seem to be using IP, but the message you got seems to be name resolution related, so not sure what's happening there. Maybe you should upgrade to the latest PsExec version.

  • If you want to use PowerShell you would use Invoke-Command -ComputerName {NameOfPC} -ScriptBlock {C:\Hyp\tom7_50080\bin\shutdown.bat}

Related Topic