Batch File to Executable
OK. I have to admit it. I got caught in a bit of a fib on Sunday. Actually, it was more of a case of bad proofreading than anything else. In my post Automatic Drive Mapping, I stated:
you can’t make a batch file into an executable
Well, wary DCoT reader D Steele caught me in my mistake and let me know that there are actually several ways that you can convert a batch file into an executable.
I had actually realized this when I was writing the previous post but promptly forgot about it before I submitted the post. So, apologies for the error.
In fact, it is really easy to do. Here is how I do it in AutoIt:
;Make batch executable #include <File.au3> Dim $TempBatchFile = _TempFile(@TempDir,"",".bat") Dim $HideConsole = False FileInstall("MyBatch.bat",$TempBatchFile) If $HideConsole Then RunWait($TempBatchFile,@TempDir,@SW_HIDE) Else RunWait($TempBatchFile,@TempDir) EndIf FileDelete($TempBatchFile) MsgBox(64,"Done","Execution complete!")
Download this code: MyBatch.au3
A couple of little things about this script. It will not show the “DOS box” as it is written. If you want to see the console screen, simply change this line:
Dim $HideConsole = False
to:
Dim $HideConsole = True
The console should now appear.
Also, the line:
FileInstall(“MyBatch.bat”,$TempBatchFile)
is where you put in the full path and name of your batch file. Simply change MyBatch.bat to the name of your batch file. You cannot use a variable for this because of how AutoIt is designed.
Once you have all of these things set, all you need to do is compile your script and you are done! Instantly compiled batch file!
If you found this post useful, why don't you buy me a cup of coffee to show your gratitude?

In one of the
I recently read on
Norm is new to Daily Cup of Tech and wants to know about the scripting language that I develop in. Norm writes:
