Jump to content
Sign in to follow this  
FinalVersion

ControlSend Questions

Recommended Posts

FinalVersion

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.

Share this post


Link to post
Share on other sites
MHz

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 this post


Link to post
Share on other sites
MHz

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 this post


Link to post
Share on other sites
MHz

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:

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.