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
Solved

AutoIT help with running .bat files?

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

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
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…
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…

808 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