For anyone who might encounter this in the future, the -c
flag does allow you to copy over a file for execution; the documentation didn't specify, but you need to follow it with the path on your local machine to the binary you want copied and executed. (I have submitted a pull request to the documentation.)
For example, this could be used to add the "Blend for Visual Studio SDK for .NET" to a remote installation of Visual Studio 2017 Professional by copying the web installer (named vs_professional.exe
) to that machine (\\TargetMachine
) with credentials, (note the DOMAIN is only if you're using a domain instead of local user), and executing it with appropriate parameters.
D:\PSTools\PsExec64.exe "\\TargetMachine" -u "DOMAIN\user" -p "pass" -h -c "D:\deploy\vs_professional.exe" vs_professional.exe modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional" --add Microsoft.Component.Blend.SDK.WPF --passive
Another contrived example:
PsExec64.exe \\Target -u user -p password -h -c "filetoremoteexec.exe" filetoremoteexec.exe --flag param1 param2