Jump to content
Sign in to follow this  
Blynx

Batch file embed

Recommended Posts

I can't figure out how to embed a batch file into the script, and have it run when a button is pressed in the GUI.

Could someone please help me?

Share this post


Link to post
Share on other sites

You can just Create a .bat in temp folder and use filewriteline to finish your batch file, finally use run() to execute it.

See now there's a problem, the program will REMOVE the temp folder...and could you possibly explain more, I only just started using autoit today.

Share this post


Link to post
Share on other sites

I can't figure out how to embed a batch file into the script, and have it run when a button is pressed in the GUI.

Could someone please help me?

You can use the following skeleton to create a batch file, then you will be able to run it as every other external command.

#include <A3LString.au3>

Local $sFile = @DesktopDir & '\' & _Str_ExtractFile(@ScriptName) & '.bat'
Local $sBAT = '@echo off' & @CRLF & _
                '[command1]' & @CRLF & _
                '[command2]' & @CRLF & _
                '[command3]' & @CRLF & _
                '[command4]' & @CRLF
                

Local $file = FileOpen($sFile, 2)

; Check if file opened for writing OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, $sBAT)

FileClose($file)

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  

×
×
  • Create New...