awaix Posted March 6, 2010 Share Posted March 6, 2010 Hi, im really new to this autoit.. ive been reading alot.. i just couldnt get how can i use cmd commands directly into autoit? like i want to use ipconfig /flushdns net stop dnscache ipconfig /flushdns net start dnscache ipconfig /flushdns but i dont knw how can just get them to do in autoit? and in administrator mode? i was able to do it by creating .bat file separatly and then executing it by requireadmin run command.. but what about having to have one one .exe? instead of having .bat and .exe? Link to comment Share on other sites More sharing options...
jamesstp20 Posted March 6, 2010 Share Posted March 6, 2010 Avec la commande Run normalement tu saurait capable de faire sa.. A+ Link to comment Share on other sites More sharing options...
darkjohn20 Posted March 7, 2010 Share Posted March 7, 2010 (edited) $CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & $CMD) Edited March 7, 2010 by darkjohn20 behdadsoft 1 Link to comment Share on other sites More sharing options...
awaix Posted March 7, 2010 Author Share Posted March 7, 2010 Avec la commande Run normalement tu saurait capable de faire sa..A+english please :$didnt understand a thing. Link to comment Share on other sites More sharing options...
awaix Posted March 7, 2010 Author Share Posted March 7, 2010 $CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & $CMD) error: Line 1(File "C:\user\awaix\desktop\test2.au3"): $CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & $CMD) $CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & ^ERROR Error: Variable used without being declared. Link to comment Share on other sites More sharing options...
darkjohn20 Posted March 7, 2010 Share Posted March 7, 2010 It needs to be on separate lines. Link to comment Share on other sites More sharing options...
awaix Posted March 7, 2010 Author Share Posted March 7, 2010 now i didnt get any error.. but i didnt see the process too.. it was just a blink.. not sure what happened in it where as flushdns takes time to complete itself.. can we do something like.. open cmd first and then execute the commands on it.. while showing whats happening?? Link to comment Share on other sites More sharing options...
darkjohn20 Posted March 7, 2010 Share Posted March 7, 2010 (edited) Look at RunWait in the Help File. $CMD = "ipconfig /flushdns" RunWait(@ComSpec & " /c " & $CMD, @WindowsDir, @SW_SHOW) Edited March 7, 2010 by darkjohn20 Link to comment Share on other sites More sharing options...
MHz Posted March 7, 2010 Share Posted March 7, 2010 The code below is perhaps worth a try as it attempts to do all 5 commands in a single CMD instance. ; Use to run the command following && only if the ; command preceding the symbol is successful. ; Cmd.exe runs the first command, and then runs ; the second command only if the first command ; completed successfully. ; Reference: ; http://technet.microsoft.com/en-us/library/bb490954.aspx $CMD = 'ipconfig /flushdns && ' & _ 'net stop dnscache && ' & _ 'ipconfig /flushdns && ' & _ 'net start dnscache && ' & _ 'ipconfig /flushdns' ; /k keeps the CMD window open. ; /c closes the CMD window once the command is complete. ; Reference: ; Type CMD /? in a command prompt window for help ; with CMD options. RunWait('"' & @ComSpec & '" /k ' & $CMD, @SystemDir) ahmeddzcom, chrisT and fraizor 3 Link to comment Share on other sites More sharing options...
darkjohn20 Posted March 7, 2010 Share Posted March 7, 2010 MHz is correct. I completely forgot about /k. Link to comment Share on other sites More sharing options...
RHaslitt Posted May 5, 2016 Share Posted May 5, 2016 What about commands like netsh when you need to us " in the command? Link to comment Share on other sites More sharing options...
Developers Jos Posted May 5, 2016 Developers Share Posted May 5, 2016 (edited) You realize this topic is some 6 years old? anyway, what exactly is your question? show the command you need and what you tried. Jos Edited May 5, 2016 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Trong Posted May 5, 2016 Share Posted May 5, 2016 3 hours ago, RHaslitt said: What about commands like netsh when you need to us " in the command? use single quotes MsgBox(32, "Set DNS 1", _DosRun('netsh interface ipv4 add dns "Local Area Connection" 8.8.8.8')) MsgBox(32, "Set DNS 2", _DosRun('netsh interface ipv4 add dns "Local Area Connection" 208.67.222.222 index=2')) Func _DosRun($sCommand) Local $nResult = Run('"' & @ComSpec & '" /c ' & $sCommand, @SystemDir, @SW_HIDE, 6) ProcessWaitClose($nResult) Return StdoutRead($nResult) EndFunc ;==>_DosRun Regards, Link to comment Share on other sites More sharing options...
Somerset Posted May 5, 2016 Share Posted May 5, 2016 Trong do you have any common sense? Link to comment Share on other sites More sharing options...
Trong Posted May 5, 2016 Share Posted May 5, 2016 3 minutes ago, Somerset said: Trong do you have any common sense? Can you tell me more, english is not my native language. "common sense" ? You want to tell me does not to reply if it has any common sense? Regards, Link to comment Share on other sites More sharing options...
Somerset Posted May 5, 2016 Share Posted May 5, 2016 This thread was abandoned 6 years ago. The only two people that should be talking this thread should be the Mod(s) and the moron that revived the thread. You inquisition of this thread was unneeded. Link to comment Share on other sites More sharing options...
Trong Posted May 5, 2016 Share Posted May 5, 2016 I thought you were too strict!Anyway, I will not repeat such an action. Thank you for your prompt. best regards, Trong Regards, Link to comment Share on other sites More sharing options...
Gianni Posted May 6, 2016 Share Posted May 6, 2016 1 hour ago, Somerset said: ... The only two people that should be talking this thread should be the Mod(s) and the moron that revived the thread.... to which of those two you belong.... lol DynamicRookie 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
StormCrowMth Posted May 4, 2018 Share Posted May 4, 2018 And so here we are again re-living a 2 year old burn. Let this be a fun reminder that a post is useful in the future and can still be expanded beyond the original question at any time. My code: $CMD = " cd C:\Users\Someone's\Desktop\Nmf\ && " & _ " 1.nmf " RunWait('"' & @ComSpec & '" /c ' & $CMD, @SystemDir) Problem: It opens the file with its default program (NICE Player if you are wondering) no problem; But my code cant continue until the cmd window closes, and it doesnt, help! best regards Link to comment Share on other sites More sharing options...
Developers Jos Posted May 4, 2018 Developers Share Posted May 4, 2018 2 minutes ago, StormCrowMth said: But my code cant continue until the cmd window closes, and it doesnt, help! That is to be expected since: RunWait() will wait until the program finishes. Run() will continue right away providing the PID of the running process. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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