Sign in to follow this  
Followers 0
hasoon2000

Run a .bat file?

31 posts in this topic

I am new to this. I am learning the program. I really suck at it lol. I am trying to make a .bat file when I press a button. All I got so far is this. I will upload the files and hopefully someone can help me. I want to press the CWM 5.0.2.7 and allow it to run the .bat file I created. (This is to make installing custom software for my Android phone a lot easier). If someone can atleast right that one code, I can learn from it and finish the rest.

http://www.mediafire.com/file/hhc23d7eg9hb2mc/Files for AutoIt.rar

Thanks!

1 person likes this

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can use Run() to tun .bat files.

Edited by hannes08

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

Can you help me link the command to the button? I have a few buttons made but I have no clue to link them.

Share this post


Link to post
Share on other sites

Can you post the script? I can't download the file (firewall restrictions). What do you mean, 'link the command to the button'? Like you have an autoit made GUI with a button that when you press you want it to run a bat?

If thats correct the help file example for GUIctrlcreatebutton is exactly what you are looking for.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

Here is the script. I also took a screenshot of the GUI. http://i44.tinypic.com/2zh1408.png

;Include Stuff

#include <ButtonConstants.au3>

#include <GUIConstantsEx.au3>

#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=c:usersodaidropboxphonesamazeguisourceamaze.kxf

$Form1_1_1 = GUICreate("HTC Amaze AIO Kit By Hasoon2000", 615, 438, 192, 124)

$Fastboot = GUICtrlCreateButton("Enter Fastboot", 16, 32, 153, 49)

$RecoveryTab = GUICtrlCreateGroup("Install Recoveries", 16, 188, 417, 56)

$CMW5027 = GUICtrlCreateButton("CWM 5.0.2.7", 32, 206, 89, 25, $BS_NOTIFY)

$CWM5504 = GUICtrlCreateButton("CWM 5.5.0.4", 133, 205, 95, 25, $BS_NOTIFY)

$TWRP2 = GUICtrlCreateButton("TWRP 2.0.0", 237, 204, 93, 25, $BS_NOTIFY)

$Stock = GUICtrlCreateButton("Stock", 336, 204, 82, 25, $BS_NOTIFY)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$UnlockBootloader = GUICtrlCreateButton("Unlock Bootloader", 440, 96, 145, 57)

$BIR = GUICtrlCreateButton("Boot into Recovery", 16, 280, 161, 49)

$TokenID = GUICtrlCreateButton("Get Token ID", 194, 29, 161, 57)

$Open = GUICtrlCreateButton("Open Folder (Place Unlock_code.bin)", 400, 32, 193, 57)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $TokenID

EndSwitch

WEnd

;Default Variables

RunWait(@CWM5027 & " /c " & "dataFlash CWM 5.0.2.7.bat")

Share this post


Link to post
Share on other sites

Case $TokenID

_Run('pathtowhatever.bat')

Didn't work. I received an error message.

Share this post


Link to post
Share on other sites

I believe JohnOne meant _rundos...but you should be able to use normal Run too.


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

I believe JohnOne meant _rundos...but you should be able to use normal Run too.

Tried rundos as well. I still received an error message.

Share this post


Link to post
Share on other sites

...What are we gonna ask you? :) can you show your exact run code as well as the error?


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Line 55 (File

"C:blah blah blah

_rundos('datatokenID.bat

^ ERROR

Error: Unknown function name.

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $TokenID

_Rundos('datatokenID.bat')

EndSwitch

WEnd

;Default Variables

RunWait(@CWM5027 & " /c " & "dataFlash CWM 5.0.2.7.bat")

Edited by hasoon2000

Share this post


Link to post
Share on other sites

I'm NOT trying to be unhelpful, only to teach you rather then giving you the answer. Lookup the helpfile for _rundos, and combine what the helpfile example has with the error message...


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

I understand. I am new to this kind of stuff. I went through the helpfile.

#include <Process.au3>

Local $rc = _RunDos("start Http://www.autoitscript.com")

Case $TokenID

Local $rc = _RunDos("dataTokenID.bat")

I tried #include as well as still got the same error message.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

You get the same, unknown func error? Can you run the example script for _rundos? I just used _rundos and run to run a .bat file, both worked just fine. Both commands will by default hide the dos window, for normal Run put @sw_show in as the flag to show your bat file as if you double clicked it.

For example... run(@desktopdir & "test.bat") works for me

Edited by someone

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

Seriously, that's all of the code you're going to post?

Did you use the line #include <Process.au3> at the top of your script when you used _RunDos? By the way, you can completely eliminate the use of _RunDos by just using this code in your script in it's place.

RunWait(@ComSpec & " /C " & "dataTokenID.bat", "", @SW_HIDE)

Then you won't need to "#include" any other functions.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

That is all the code there is.

I tried "RunWait(@ComSpec & " /C " & "dataTokenID.bat", "", @SW_HIDE)" and no dice.

I made a new empty script so I can do the code you provided "run(@desktopdir & "test.bat")" and no dice as well.

Share this post


Link to post
Share on other sites

I am trying to make a toolkit like this

http://forum.xda-developers.com/showthread.php?t=1090783

He does not used .bat commands so it makes it harder for me to look at. He posted his source code and I guess I do not understand it.

He offers his source code here

http://www.mediafire.com/?5gxuw9db66k656i

Share this post


Link to post
Share on other sites

That is all the code there is.

I tried "RunWait(@ComSpec & " /C " & "dataTokenID.bat", "", @SW_HIDE)" and no dice.

I made a new empty script so I can do the code you provided "run(@desktopdir & "test.bat")" and no dice as well.

What exactly is "no dice" supposed to tell us? What didn't work as intended or what error message did you receive?

Where is the TokenID.bat file located in relation to where the script is being run from? Have you tried running the batch file with the full path instead of a relative path? If you use the RunWait command without the @SW_HIDE parameter do you get any output in the command window?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Yeah please be a lot more specific. Separate the bat file not executing the way you intended it to run, and Autoit not running the .bat file at all.

Make a dummy bat script with only pause, so you can see when it runs. Do not use the hide flag.

Do your bat file(s) execute as you intend when you double click them, or run them from within dos?

ALWAYS - what are your error messages and where did they come from. I really like DaleHohm's sig - 'Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?'


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

As a follow up, please click on the very large link in my signature and read it very carefully. You'd be amazed at the responses you receive when you form a coherent question and then describe in detail what your problem is rather than throwing out "no dice". This document that it links to has been translated into at least 19 languages, so hopefully your's is one of them and it won't be a problem to read it carefully.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0