Solved

AutoIT help with running .bat files?

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

Suggested Solutions

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
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 dynamically set the form action using jQuery.

919 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now