Reputation: 403
I'm trying to open a CMD as system using PowerShell and then send a command to that system window. what i've got so far is this:
$opensystempromt = '"/c PsExec.exe -is cmd.exe'
[System.Diagnostics.Process]::Start('cmd.exe',$opensystempromt)
$systemcommand = 'CustomerService.exe deploy aa.txt bb.txt'
what i can't figure out is how to send the system command to the newly opened CMD. and there's no documentation for it anywhere, that i could find
Upvotes: 0
Views: 62
Reputation: 180
I'd use Start-Process
to open cmd.
Start-Process -FilePath "C:\Windows\System32\cmd.exe" -verb runas -ArgumentList {/k Insert your variables here}
with -verb runas
you'll open cmd as an administrator. ArgumentList
is your "command part". /k
leaves the cmd open, after the commands are done. If you want cmd to close instead, use /c
.
Upvotes: 1