Jump to content
Sign in to follow this  
Guest Guidosoft

Batch File Embedded into script.

Recommended Posts

Guest Guidosoft

Example of script taking it upon itself to execute a batch file without showing it, and showing echos in a msgbox.

;Batch File embedded into script.
;Author: Guido Arbia

;DATA STRUCTURE "BATCH FILE"
;ECHO THIS IS TEXT >> C:\Windows\Desktop\Spmething.txt
;REN C:\Windows\Desktop\Something.txt Florp.txt
;ECHO THIS IS A GUTTER MOUTH CONVENTION >> C:\Windows\Desktop\Florp.txt
;MOVE C:\Windows\Desktop\Florp.txt C:\Wip.ini
;ECHO HELLO WORLD FROM MORON TOWN!!!
;END DATA STRUCTURE

#include "ScriptInternalData.AU3"

$BatData = ExtractDataStructure("BATCH FILE")

If @Compiled then 
   msgBox(0,"WTF", "This script only works open-source. OK!!!!")
   Exit
EndIf

For $I = 1 to $BatData[0]
   If StringLeft($BatData[$I],4) <> "ECHO" then
      Run(@Comspec & " /C " & $BatData[$I],"",@SW_HIDE)
   Else
      If not StringInStr($BatData[$I], ">>") then
         $BatData[$I] = StringReplace($BatData[$I],"ECHO.","ECHO")
         $BatData[$I] = StringReplace($BatData[$I],"ECHO  ","ECHO ")
         MsgBox(0,"BATCH FILE",StringTrimLeft($BatData[$I],5))
      Else
         Run(@Comspec & " /C " & $BatData[$I],"",@SW_HIDE)
      EndIf
   EndIf
Next

;END OF FILE

ScriptInternalData.AU3 can be found at:

http://www.AutoItScript.com/fileman/users/public/Guidosoft

Edited by Guidosoft

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...