Jump to content

ControlSend Questions

Recommended Posts

Lets say I've run this.

Run(@ComSpec & "ping google.com -n 100")

The only way to stop it is with Ctrl+C. Now seeing as I haven't used /k, the Command Prompt window isn't visible. How can I send Ctrl+C? I'm 99.9% sure I can use "ControlSend", but I don't know for certain, or know how to do it.

Link to comment
Share on other sites

The syntax seems to be incorrect. i.e path\to\cmd.exeping

Run() does return the ProcessID. You can just use ProcessClose($pid) if $pid contains value that resulted form Run() i.e $pid = Run('some file').

Or Using RunWait() and the /c switch on @Comspec seems like a better concept to me.

Unless you wish to be more gracious about the procedure and make it harder for yourself then what perhaps is needed.

Link to comment
Share on other sites

Ah, Lets just say half way through the command, I wanted to end it. Not when the command is finished. :(

As in a single CMD command?

You could ProcessClose() it.

Perhaps the best way to control CMD (@Comspec) is by using the STDIN, STDOUT and/or STDERR parameters in Run(). Something for you to play with. :mellow:

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...