power1power1 Posted November 6, 2013 Share Posted November 6, 2013 (edited) Hello, I was hoping to have a special autoit function to handle Windows batch file commands, something like this: autoit commands batchfile() autoit commands func batchfile() batch file commands endfunc Edited November 6, 2013 by power1power1 Link to comment Share on other sites More sharing options...
Jfish Posted November 6, 2013 Share Posted November 6, 2013 (edited) You can shellexecute a batch file within your function. You can also run DOS console commands with Run ... To run DOS (console) commands, try Run(@ComSpec & " /c " & 'commandName', "", @SW_HIDE) ; don't forget " " before "/c" Edited November 6, 2013 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2013 Share Posted November 6, 2013 Anything written for a batch file can be replaced with the appropriate AutoIt code. Blue_Drache 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
power1power1 Posted November 6, 2013 Author Share Posted November 6, 2013 Yes, thanks for the replies. Still, having such a special function would be nice. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 6, 2013 Developers Share Posted November 6, 2013 Wondering which functionality in AUtoIt3 is missing for you to propose this? 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...
power1power1 Posted November 6, 2013 Author Share Posted November 6, 2013 (edited) Oh well, from functionality point of view, you can call a batch file from within an autoit script. However, what I was asking is a different way of doing it. You would insert your batch commands whithin a special function that would reside inside the autoit script. So, if you share your complied autoit code with others, you would provide them with the autoit file only, rather than the autoit file plus a bunch of related batch files. Any ways, it's wishful thinking, I guess. Edited November 6, 2013 by power1power1 Link to comment Share on other sites More sharing options...
BrewManNH Posted November 6, 2013 Share Posted November 6, 2013 But why would you NEED the batch files or their commands, if the autoit script can do it, without resorting to using a command from another language? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
power1power1 Posted November 6, 2013 Author Share Posted November 6, 2013 (edited) We can think of senarios that this would become handy: You would take your old batch files and just reuse the code, rather than rewriting them ... Edited November 6, 2013 by power1power1 Link to comment Share on other sites More sharing options...
Chimaera Posted November 6, 2013 Share Posted November 6, 2013 I used to use a lot of batch stuff when i first started but i can assure you there is very little need for it as i have gradually moved my scripts into AutoIt and i would never go back as i have added functionality now which i couldn't get just with batch. I still use robocopy and stuff like that but i control it from AutoIt nowadays and i have never had a situation where having batch code would be usefull. Up to you of course If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() Link to comment Share on other sites More sharing options...
Carlo84 Posted November 6, 2013 Share Posted November 6, 2013 (edited) You can do exactly what you want with the run function http://www.autoitscript.com/autoit3/docs/functions/Run.htmRead the remarksAlso a tip to run several commands on one line you can seperate commands with the pipe character.To get return valuess you have to use StdoutRead and StderrReadToo much trouble then it's worth to re-invent the wheel Edited November 6, 2013 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
power1power1 Posted November 6, 2013 Author Share Posted November 6, 2013 Thank you guys for the replies. I just want to emphasis again that the point was to prevent putting effort on the code rewriting/converting process, else you would just do the whole thing entirely in autoit. Link to comment Share on other sites More sharing options...
BrewManNH Posted November 7, 2013 Share Posted November 7, 2013 If you're looking to directly run the batch file commands in an AutoIt script then your answer is, you can't. The 2 languages aren't compatible. If you want to run batch files then use batch files, you can always FileInstall them into a compiled script and delete when done with them. Or you can put the batch commands into the script, write a batch file when the script is run, run the batch file, and then delete it when done. See the _SelfDelete function in the example scripts forum to see how he did it with VBscript code, same concept. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Solution power1power1 Posted November 7, 2013 Author Solution Share Posted November 7, 2013 This would be a good workaround ... I guess one can create a temporary batch file in Windows temp directory, copy the text commands to the batch file, run the batch file and then delete the batch file when done. 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