?
Solved

AutoIT help with running .bat files?

Posted on 2010-08-12
4
Medium Priority
?
4,313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

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

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Suggested Courses

771 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