Solved

AutoIT help with running .bat files?

Posted on 2010-08-12
4
3,806 Views
Last Modified: 2013-04-26
I am very new to AutoIT but it looks like an interesting tool to use so I thought I would give it a try.  I am wanting to create a menu with 4 buttons that when clicked will just point to 4 different bat files depending on which button is clicked.  The bat files should be able to finish the installs for what I am wanting so I'm pretty sure that's all I need from AutoIT is just to create the menu and the buttons.  How do you point the button to a specific bat file.
0
Comment
Question by:Justin2135
  • 3
4 Comments
 
LVL 29

Expert Comment

by:matrixnz
ID: 33427277
Run(@ComSpec & ' /C <Batch File Name>', '', @SW_HIDE)
0
 
LVL 29

Expert Comment

by:matrixnz
ID: 33427292
More complete example
GUICreate('My App', 400, 20)
$Button1 = GUICtrlCreateButton('Button 1', 0, 0, 100, 20)
$Button2 = GUICtrlCreateButton('Button 2', 100, 0, 100, 20)
$Button3 = GUICtrlCreateButton('Button 3', 200, 0, 100, 20)
$Button4 = GUICtrlCreateButton('Button 4', 300, 0, 100, 20)
GUISetState()

While 1
	$msg = GUIGetMsg()
	Select
		Case $msg = $GUI_EVENT_CLOSE
			ExitLoop
		Case $msg = $Button1
			Run(@ComSpec & ' /C <Batch File 1 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button2
			Run(@ComSpec & ' /C <Batch File 2 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button3
			Run(@ComSpec & ' /C <Batch File 3 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button4
			Run(@ComSpec & ' /C <Batch File 4 Name>.bat', '', @SW_HIDE)
	EndSelect
WEnd

Open in new window

0
 
LVL 29

Accepted Solution

by:
matrixnz earned 500 total points
ID: 33427298
Sorry forgot to put the top line #include <GUIConstantsEx.au3>

Full Code Below
#include <GUIConstantsEx.au3>

GUICreate('My App', 400, 20)
$Button1 = GUICtrlCreateButton('Button 1', 0, 0, 100, 20)
$Button2 = GUICtrlCreateButton('Button 2', 100, 0, 100, 20)
$Button3 = GUICtrlCreateButton('Button 3', 200, 0, 100, 20)
$Button4 = GUICtrlCreateButton('Button 4', 300, 0, 100, 20)
GUISetState()

While 1
	$msg = GUIGetMsg()
	Select
		Case $msg = $GUI_EVENT_CLOSE
			ExitLoop
		Case $msg = $Button1
			Run(@ComSpec & ' /C <Batch File 1 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button2
			Run(@ComSpec & ' /C <Batch File 2 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button3
			Run(@ComSpec & ' /C <Batch File 3 Name>.bat', '', @SW_HIDE)
		Case $msg = $Button4
			Run(@ComSpec & ' /C <Batch File 4 Name>.bat', '', @SW_HIDE)
	EndSelect
WEnd

Open in new window

0
 
LVL 3

Expert Comment

by:gimosuby
ID: 33428768
If I were you I'd convert the bat files to AutoIT as wel. Take a look a the AutoIT help file, it's very elaborate..
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question