简体   繁体   中英

how to run "start-process test.bat " in powershell context

I dont know if this is the right question that i am asking. Please correct me if i am wrong here.

Query:

I am trying to run a windows Traffic tool "NTTtcp" using a batchfile. I trigger the command remotely on to the windows as "start-process test.bat"

So the batchfile execution spawns a cmd window and executes there.

1) Is there a way to stop this spawning of a new window? 2) Is there a way to run the same in powershell mode rather than DOS mode 3) Is there a way to capture the output that is run on a new cmd window as i have used redirection operator and nothing works. Have also checked the possibility of clip too but that does not work too.

-Aprameya

For the running without a window, below is the code to add to the top of your batch which will launch it minimized as suggested by Andrew.

@echo off
if not "%minimized%"=="" goto :minimized
set minimized=true
start /min cmd /C "%~dpnx0" %*
goto :EOF
:minimized

As for a PowerShellequivalent of NTTtcp, I think you are SOL for something that well made. Maybe exporting the results from the CMD window to a .txt file and parsing them would be cleaner, if you are that hung up on having it in PowerShell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM