# 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.

Anyone?

##### 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.

##### Share on other sites

I'm open to suggestions, but what does "/c" do?

##### Share on other sites

I'm open to suggestions, but what does "/c" do?

If you know how to use a command prompt then try typing in cmd /? and pressing the return key.

/c automatically terminates the cmd process once the commands passed are complete.

##### Share on other sites

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

##### 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.

##### Share on other sites

Actually never mind, I got it myself.

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

And if I wanted to end it simply.

ProcessClose("cmd.exe")

## Create an account

Register a new account

×

• Wiki

• Back

• Git