I want to achieve following in one single command.
PS D:\custom> .\PsExec.exe \remoteserver -u user -p password -accepteula -s cmd PsExec v2.34 - Execute processes remotely Copyright (C) 2001-2021 Mark Russinovich Sysinternals - www.sysinternals.com Microsoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved. C:\Windows\system32>D: D:\ cd test D:\test>testjob.bat D:\test>hostname windowsrundeck
I don't want to copy my bat file from my local machine to remote machine. instead I want to directly execute a bat file present in D:\test folder of remote machine.
Also, Is it possible to run multiple commands in one psexec command ?
Also, If I use this psexec command in automation tool, it just gives me exit code, note verbose of what it has done.. How can I see what my bat file is doing when I run my psexec command from automation tool?
I managed to fix it by adding all commands in one bat file. and I was able to execute the batfile in D:\test by using -w parameter in psexec command. -w sets the working directory on remote machine.