MyDream Posted July 17, 2007 Share Posted July 17, 2007 I just need to run the whole batch file command script inside the autoit script itself, not embedded the .bat file into the exe. Anyone have any ideas how to do it? Thanks in advance. Link to comment Share on other sites More sharing options...
SkiFreak Posted July 17, 2007 Share Posted July 17, 2007 Search Run and RunWait in the AutoIt help. Depending on how complex the batch file is, it may be a simple case of rewriting the batch file in AutoIt format. eg. RunWait(@comspec & " \C IPCONFIG /ALL > C:\Temp\IP.txt","",@SW_HIDE) Link to comment Share on other sites More sharing options...
ChrisL Posted July 17, 2007 Share Posted July 17, 2007 It depends on what commands your trying to run you may be able to do them with just autoit. If not you can fileinstall() the batchfile which you don't seem keen on or you could write the batchfile out with autoit using filewrite() or filewriteLine() then run it using Run() [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
MyDream Posted July 17, 2007 Author Share Posted July 17, 2007 Sample bat file @ECHO OFF Color F7 IF NOT EXIST "C:\Program Files\Test1\Testrun.exe" GOTO THEEND IF NOT EXIST "C:\My Files\Test2.exe" GOTO THEEND "C:\Program Files\Test1\Testrun" reg import "C:\My Files\Test1Run.reg" IF %COMPUTERNAME%==Jacky GOTO END IF %COMPUTERNAME%==Lilian GOTO END IF %COMPUTERNAME%==Personal GOTO END :THEEND EXIT :END CLS Call "C:\Program Files\Test2\Start.exe" -i "C:\Program Files\Yahoo!\Messenger\Run.exe" -s EXIT Something like the above. Link to comment Share on other sites More sharing options...
ChrisL Posted July 17, 2007 Share Posted July 17, 2007 (edited) Autoit Code IF NOT FileEXISTs ("C:\Program Files\Test1\Testrun.exe") then TheEnd() IF NOT FileEXISTs ("C:\My Files\Test2.exe") Then TheEnd() RunWait("C:\Program Files\Test1\Testrun.exe","C:\Program Files\Test1") Run ("Regedit /s C:\My Files\Test1Run.reg") IF @computername = "Jacky" Then END() IF @computername = "Lilian" Then END() IF @computername = "Personal" Then END() EXIT Func END() Run (FilegetShortName("C:\Program Files\Test2\Start.exe") & " -i","C:\Program Files\Test2") Run (FileGetShortName("C:\Program Files\Yahoo!\Messenger\Run.exe") & " -s","C:\Program Files\Yahoo!\Messenger") EXIT EndFunc Func TheEnd() Exit EndFunc Simplified version IF NOT FileEXISTs ("C:\Program Files\Test1\Testrun.exe") then Exit IF NOT FileEXISTs ("C:\My Files\Test2.exe") Then Exit RunWait("C:\Program Files\Test1\Testrun.exe","C:\Program Files\Test1") Run ("Regedit /s C:\My Files\Test1Run.reg") IF @computername = "Jacky" or @computername = "Lilian" or @computername = "Personal" Then Run (FilegetShortName("C:\Program Files\Test2\Start.exe") & " -i","C:\Program Files\Test2") Run (FileGetShortName("C:\Program Files\Yahoo!\Messenger\Run.exe") & " -s","C:\Program Files\Yahoo!\Messenger") EndIf Edited July 17, 2007 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
MyDream Posted July 17, 2007 Author Share Posted July 17, 2007 Autoit Code IF NOT FileEXISTs ("C:\Program Files\Test1\Testrun.exe") then TheEnd() IF NOT FileEXISTs ("C:\My Files\Test2.exe") Then TheEnd() RunWait("C:\Program Files\Test1\Testrun.exe","C:\Program Files\Test1") Run ("Regedit /s C:\My Files\Test1Run.reg") IF @computername = "Jacky" Then END() IF @computername = "Lilian" Then END() IF @computername = "Personal" Then END() EXIT Func END() Run (FilegetShortName("C:\Program Files\Test2\Start.exe") & " -i","C:\Program Files\Test2") Run (FileGetShortName("C:\Program Files\Yahoo!\Messenger\Run.exe") & " -s","C:\Program Files\Yahoo!\Messenger") EXIT EndFunc Func TheEnd() Exit EndFunc Simplified version IF NOT FileEXISTs ("C:\Program Files\Test1\Testrun.exe") then Exit IF NOT FileEXISTs ("C:\My Files\Test2.exe") Then Exit RunWait("C:\Program Files\Test1\Testrun.exe","C:\Program Files\Test1") Run ("Regedit /s C:\My Files\Test1Run.reg") IF @computername = "Jacky" or @computername = "Lilian" or @computername = "Personal" Then Run (FilegetShortName("C:\Program Files\Test2\Start.exe") & " -i","C:\Program Files\Test2") Run (FileGetShortName("C:\Program Files\Yahoo!\Messenger\Run.exe") & " -s","C:\Program Files\Yahoo!\Messenger") EndIf Thanks for the help, you give me roughly hows its done in autoitscript, although it'll take me sometime to do it since my batch script very long. But thank very much. I'll know what to do with it. Link to comment Share on other sites More sharing options...
SadBunny Posted July 17, 2007 Share Posted July 17, 2007 Thanks for the help, you give me roughly hows its done in autoitscript, although it'll take me sometime to do it since my batch script very long. But thank very much. I'll know what to do with it.Maybe a suggestion:Estimate the time it will take you to manually rewrite all batch instructions to AutoIt format.Then check that against the estimated time of writing a function to convert (some part of?) the batch instructions into autoit format automatically, added to the "experience points" gained by it.See, if you have 200 batch instructions of which many (if not all) are very similar, you will probably be way better off investing in writing a conversion function Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
MyDream Posted July 17, 2007 Author Share Posted July 17, 2007 Maybe a suggestion:Estimate the time it will take you to manually rewrite all batch instructions to AutoIt format.Then check that against the estimated time of writing a function to convert (some part of?) the batch instructions into autoit format automatically, added to the "experience points" gained by it.See, if you have 200 batch instructions of which many (if not all) are very similar, you will probably be way better off investing in writing a conversion function Actually, my batch file is way more complex than the one I posted here, but too bad, when it comes to Autoit script, Im still a beginner, writing an Autoit script to convert all my batch files into autoit scripts are too difficult for me. I'll take my time unless I can find certain programs to do it. The reason I wanted to use Autoit script instead of normal bat program is because most bat to exe programs have problems with antivirus programs now. So far, no perfect solution yet, its either use these programs without antivirus or find an alternate program to perform these functions and use together with an antivirus.I'll take my time to convert these batch files, hopefully. Link to comment Share on other sites More sharing options...
SadBunny Posted July 17, 2007 Share Posted July 17, 2007 Actually, my batch file is way more complex than the one I posted here, but too bad, when it comes to Autoit script, Im still a beginner, writing an Autoit script to convert all my batch files into autoit scripts are too difficult for me. I'll take my time unless I can find certain programs to do it. The reason I wanted to use Autoit script instead of normal bat program is because most bat to exe programs have problems with antivirus programs now. So far, no perfect solution yet, its either use these programs without antivirus or find an alternate program to perform these functions and use together with an antivirus.I'll take my time to convert these batch files, hopefully.Hmm... Just out of curiosity... I am pretty puzzled by why you can't just FileInstall() the batch files, or put everything in strings and write the batchfiles when needed? Maybe there's still some time to save by reviewing your approach? Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
MyDream Posted September 5, 2007 Author Share Posted September 5, 2007 Hmm... Just out of curiosity... I am pretty puzzled by why you can't just FileInstall() the batch files, or put everything in strings and write the batchfiles when needed? Maybe there's still some time to save by reviewing your approach?For securit reason of course. Anyway, lets saidif computer name = joan then perform this function 1 and function z then exit.if computer name = john then perform this function 2 and function z then exit......if computer name = ellen then perform this function 20 and function z then exit.Lets say I got 10 or more computers, each computer perform one fucntion specifically for that computer and another funciton that is same for all computers. Beside doing it like one statement by statement like the above, is there any other way to do it or program it. For batch, its normally statement by statement, what about autoitscript?Thanks. Link to comment Share on other sites More sharing options...
ChrisL Posted September 5, 2007 Share Posted September 5, 2007 Do you mean like this? Switch @ComputerName Case "Joan" Function1() Case "John" Function2() Case "Ellen" Function20() Case Else Exit EndSwitch Functionz() Func Function1() ;Do stuff EndFunc Func Function2() ;Do stuff EndFunc Func Function20() ;Do stuff EndFunc Func Functionz() ;Do stuff for everybody EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
MyDream Posted September 5, 2007 Author Share Posted September 5, 2007 Do you mean like this? Switch @ComputerName Case "Joan" Function1() Case "John" Function2() Case "Ellen" Function20() Case Else Exit EndSwitch Functionz() Func Function1() ;Do stuff EndFunc Func Function2() ;Do stuff EndFunc Func Function20() ;Do stuff EndFunc Func Functionz() ;Do stuff for everybody EndFunc Thanks for your help. Its cool since I havent figure out all the functions and commands that I can use in autoitscript. Hehe. One thing though, anyway we can just compare the joan1 and joan2 computernames for just the 4 characters in front like for computer in joanXXX will perform this function for it? Link to comment Share on other sites More sharing options...
ChrisL Posted September 5, 2007 Share Posted September 5, 2007 Thanks for your help. Its cool since I havent figure out all the functions and commands that I can use in autoitscript. Hehe. One thing though, anyway we can just compare the joan1 and joan2 computernames for just the 4 characters in front like for computer in joanXXX will perform this function for it? Switch StringLeft(@computername,4) Case "Joan" Function1() Case "John" Function2() Case "Elle";have to shorten this one to the first 4 characters! Function20() Case Else Exit EndSwitch Functionz() [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted September 5, 2007 Share Posted September 5, 2007 I'd probably make your function names a bit more relevant too. Func John() Endfunc Func Joan() Endfunc Etc etc.. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now