Jump to content

Batch file embed


Blynx
 Share

Recommended Posts

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.

Link to comment
Share on other sites

  • 1 month later...

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)
Link to comment
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
 Share

  • Recently Browsing   0 members

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