-2

We're running following command line

C:\Util\SysinternalsSuite\psexec \\10.120.36.219 -u localhost\account -p Password -h -w C:\Temp\FOLDER C:\Temp\FOLDER\postinstallphase1.cmd

Where the postinstallphase1.cmd script contains a set of commands that temporarily break the connection to the target server. Due to these commands, the psexec gets stuck and the only way to get command prompt is press enter in cmd console.

This is a problem for us since we plan to use this command in an unattended solution.

We've tried as well to use the '-d' argument but for unknown reason if we run the command with this argument the cmd script does not behave as expected (as it does without -d).

Is there any way to simulate someone pressing the enter key?

2 Answers2

2

According to: https://serverfault.com/questions/437504/why-does-psexec-hang-after-successfully-running-a-powershell-script

you can fix that issue by piping the command in like this:
psexec \\target -u domain\username -p password cmd /c "echo . | powershell c:\path\script.ps1"

Community
  • 1
  • 1
Michael
  • 21
  • 2
0

Thanks for help.

I used this for send Zabbix Agent installation on remote Windows servers with PsExec from Sysinternals suite.

This is my command:

PsExec.exe @servers_list.txt
-accepteula
-n 5
-h
-u "Administrator"
cmd /c
"echo . | C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
-ExecutionPolicy ByPass
-File \\share\public\zabbix_agent_install_windows.ps1"
Jorge E. Hernández
  • 2,800
  • 1
  • 26
  • 50
HUM4N
  • 1
  • 1