Jump to content

Combining Batch File Commands with Autoit Commands


Go to solution Solved by power1power1,

Recommended Posts

Posted (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 by power1power1
Posted

Anything written for a batch file can be replaced with the appropriate AutoIt code.

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 Gude
How 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

Posted (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 by power1power1
Posted

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 Gude
How 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

Posted (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 by power1power1
Posted

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

Posted (edited)

You can do exactly what you want with the run function http://www.autoitscript.com/autoit3/docs/functions/Run.htm

Read the remarks

Also 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 StderrRead

Too much trouble then it's worth to re-invent the wheel

Edited by Djarlo
Posted

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.

Posted

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 Gude
How 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

  • Solution
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...