random8011 Posted August 6, 2004 Share Posted August 6, 2004 if i want to do "ping 10.0.0.1 -t" in cmd mode.i just userun("ping 10.0.0.1 -t")but i have just seen this To run DOS (console) commands, try RunWait(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)so i use thisrunwait( @comspec & " /c ping 10.0.0.1 -t","",@SW_HIDE)which is the correct or better way to run Dos commands? mr-es335 1 Link to comment Share on other sites More sharing options...
ezzetabi Posted August 6, 2004 Share Posted August 6, 2004 If it is a internal command you have to use @comspec otherwise you can use Run() Usually I prefere using always @comspec since it seems more tidy to me. Also it is more bulletproof, some commands seems dislike Run() and other are internal in Win2000 and external in W9x. Link to comment Share on other sites More sharing options...
pekster Posted August 6, 2004 Share Posted August 6, 2004 If you use the ComSpec method as you wrote it, it will run in a hidden comand window. However, you will have no way to get the output from the window unless you pipe it to a file (example, run @ComSpec & " /c dir > directory.txt").However, I think I have a better solution for you. Do you only care about the success or failure of the ping? If so, consider using RunWait for your ping (without the @ComSpec, so just RunWait("ping 10.0.0.1") ,which will return the error code of the process you launched when it finishes. If you store this return to a variable, you can gether the success or failure of the ping.Using the method you posted at the bottom is pointless because it is going to run a command that will never end (due to the -t switch), it will run in a hidden window, and it will not dump the output to any file. It's just eating CPU cycles and resources on your system. A hidden window is only used when you don't need any output, or you're piping the output to a file to read later. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
pekster Posted August 6, 2004 Share Posted August 6, 2004 (edited) Usually I prefere using always @comspec since it seems more tidy to me. Also it is more bulletproof, some commands seems dislike Run() and other are internal in Win2000 and external in W9x. <{POST_SNAPBACK}>But you can't get the return (see note) out of that method. There are times when you don't want to use it. Also, because of the problem random8011 mentioned above, if you want the program's window to be hidden from the start, you need to run the handler app directally, and not through ComSpec. Some things cannot be done by passing it through the command interperter. It's not a matter of how "neat" it looks, but if you need the error code, and what else you want to do. Edit (note): By "return" I mean the exit code of the process that was launched; all you will get if you use @ComSpec is the exit code of the dos window, and this can (should???) be different than the exit code of the application that you ran through the command interperter. Edited August 6, 2004 by pekster [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. Link to comment Share on other sites More sharing options...
random8011 Posted August 6, 2004 Author Share Posted August 6, 2004 If you use the ComSpec method as you wrote it, it will run in a hidden comand window. However, you will have no way to get the output from the window unless you pipe it to a file (example, run @ComSpec & " /c dir > directory.txt").i am so sorry i made a wrong example.i really want to do like this:run this Dos command in my scirpt:regedit -s oracle.regfirst i write this1.runwait("regedit -s oracle.reg")i tested it,seems ok.But in my two scripts,both have 1 .one script takes effect,another doesn't.SO i write this:2.runwait( @comspec & " /c regedit -s oracle.reg","",@SW_HIDE)2 takes effect in both two scripts.i don't understand why 1 doesn't take the same effect in my two scripts.and,i want to know the different between 1 and 2 function?i am sorry for my poor english........... Link to comment Share on other sites More sharing options...
ezzetabi Posted August 6, 2004 Share Posted August 6, 2004 @comspec look in the whole %Path% of Windows runwait() only in the @workingdir (if not path are present, of course) Ay least... I think so. Link to comment Share on other sites More sharing options...
igoryonya Posted November 16, 2004 Share Posted November 16, 2004 @comspec look in the whole %Path% of Windowsrunwait() only in the @workingdir (if not path are present, of course)Ay least... I think so.<{POST_SNAPBACK}>@comspec is a path to cmd.exeRunWait is a function that once called, autoit script pauses execution until executed program exits.Run is a function that doesn't pause autoit script execution after it's execution. The script continues execution at the same time as the Runned program Runs. AltereEgo 1 Link to comment Share on other sites More sharing options...
amouna98 Posted July 16, 2010 Share Posted July 16, 2010 @comspec is a path to cmd.exeRunWait is a function that once called, autoit script pauses execution until executed program exits.Run is a function that doesn't pause autoit script execution after it's execution. The script continues execution at the same time as the Runned program Runs.j'ai presque le meme probleme, je veux lancer la commande dosisql -User -Pass -SSql -i D:\dev\db_history.sql -Dsystem > DBHistory.outj ai essayé comme ca mais ca marche pas run (@ComSpec & "/c isql -User -Pass -SSql -i D:\dev\db_history.sql -Dsystem > DBHistory.out") Link to comment Share on other sites More sharing options...
amouna98 Posted July 16, 2010 Share Posted July 16, 2010 @comspec is a path to cmd.exeRunWait is a function that once called, autoit script pauses execution until executed program exits.Run is a function that doesn't pause autoit script execution after it's execution. The script continues execution at the same time as the Runned program Runs.j'ai presque le meme probleme, je veux lancer la commande dosisql -User -Pass -SSql -i D:\dev\db_history.sql -Dsystem > DBHistory.outj ai essayé comme ca mais ca marche pas run (@ComSpec & "/c isql -User -Pass -SSql -i D:\dev\db_history.sql -Dsystem > DBHistory.out") Link to comment Share on other sites More sharing options...
mr-es335 Posted September 13 Share Posted September 13 random8011, Thanks for this...very much appreciated!! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now