Sign in to follow this  
Followers 0
6105

Command Line

9 posts in this topic

How to send command to cmd? like "ping 8.8.8.8"

i have tryed this:

Run(@ComSpec & " /k" & "ping 8.8.8.8 -t>" & Random(1,999999) & ".xml")

but not all work propriety, somebody know another solution? thanks.


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites



Try this:

Run(@ComSpec & " /k" & "ping 8.8.8.8 -t> c:\123.txt")

As you can see it works. You have forgotten to add c:\ (for example) in the file path.

Share this post


Link to post
Share on other sites

What he said.

It's executing the command but not generating the file where you think it should be (it is generating wherever the default working dir is).

You can set it to your script dir or control the path by using the working dir parameter of run as well

Run(@ComSpec & " /k" & "ping 8.8.8.8 -t>" & Random(1,999999) & ".txt", @ScriptDir)

You can also pull the Random function out of the run command and assign it to a variable so you can know what file name is being generated.

$sFile = Random(1,999999) & ".txt"
RunWait(@ComSpec & " /k" & "ping 8.8.8.8 -t>" & $sFile, @ScriptDir)

ShellExecute($sFile, "", @ScriptDir, "Edit")

Share this post


Link to post
Share on other sites

Make sure there is a spaces between /K and PING !

Why does everyone like to concatenate literal strings this way in stead of simply using one string? :x


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Run ( @ComSpec & " /k ping 8.8.8.8 >" & Random(1,999999) & ".xml", '', @SW_HIDE )

otherwise you have the AutoIt Ping function...

$var = Ping ( '8.8.8.8', 250 )
If $var Then; also possible:  If @error = 0 Then ...
    Msgbox ( 0,"Status","Online, roundtrip was:" & $var )
Else
    Msgbox ( 0,"Status","An error occured with number: " & @error )
EndIf

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

1/ I dont see why im hijacking this treah is about using autoit to lauch a command , ping was stated as an example.

Because I said so.

Your and related posts are removed from the thread and better stop arguing about it in this topic.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Hi, am about another function if i use Run ( @ComSpec ) that is not flexibility,

have the Autoit something more easy? what will give command to RUN?

bc, if you'll give command in RUN "ping 8.8.8.8" will do the function, and after will be automatic closed.


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

Share this post


Link to post
Share on other sites

Hi, am about another function if i use Run ( @ComSpec ) that is not flexibility,

have the Autoit something more easy? what will give command to RUN?

bc, if you'll give command in RUN "ping 8.8.8.8" will do the function, and after will be automatic closed.

What do you mean? its flexible enough when you understand how things work.

/k will leave the CMD session open and /c will close it after you are done.

... or am I misinterpreting what you wrote? :x


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thank you :x


[center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Don't utter a single word[/font][/center][center][font=courier new,courier,monospace]Die die die my darling[/font][/center][center][font=courier new,courier,monospace]Just shut your pretty mouth[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you again[/font][/center][center][font=courier new,courier,monospace]I'll be seeing you[/font][/center][center][font=courier new,courier,monospace]In hell[/font][/center]

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  
Followers 0