I'm starting the PsExec using Powershell:

Start-Process -FilePath "psexec.exe" -ArgumentList "-u user -p pass -accepteula -i -h cmd /c `"powershell.exe -NonInteractive -File myscript.ps1`""

But the PsExec CMD is visible until the powershell script myscript.ps1 is finished.

So how can I hide PsExec CMD ?


Solution 1:

I asked the wrong question.

Since I'm starting the PsExec using Start-Process then I can control it very easily with -windowstyle hidden as explained on the link https://stackoverflow.com/questions/1802127/how-to-run-a-powershell-script-without-displaying-a-window which was posted by @Christoper Hostage