Solved

AutoIT help with running .bat files?

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
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 if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

762 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

20 Experts available now in Live!

Get 1:1 Help Now