Solved

AutoIT help with running .bat files?

Posted on 2010-08-12
4
4,009 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 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

726 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