Huntknife Posted February 27, 2020 Share Posted February 27, 2020 Could someone help me to change Bat Code to Autoit code? Becouse i know that you cant change bat file to Autoit exe until you change the code language right? expandcollapse popup@echo off :menu ECHO. ECHO .................... ECHO Spausti 1 - Change ip ECHO Spausti 2 - Start ping ECHO Spausti 3 - Open google chrome ECHO .................... ECHO. echo= IP Change: %IP% echo. CHOICE /C:123 IF ERRORLEVEL 1 SET M=1 IF ERRORLEVEL 2 SET M=2 IF ERRORLEVEL 3 SET M=3 IF %M%==1 GOTO start IF %M%==2 GOTO ping IF %M%==3 GOTO chrome :start echo. set /p IP= Change IP= netsh interface ipv4 set address name="Eternetas" static %IP% 255.255.255.0 echo. cls goto menu :ping echo. set /p Ping= Ping ip= echo. Ping %Ping% -t pause cls goto menu :chrome start "" www.google.com cls goto menu The main question can Autoit do these things? Link to comment Share on other sites More sharing options...
Subz Posted February 27, 2020 Share Posted February 27, 2020 AutoIt can do this, you can call the commands via Run i.e. Example (untested) Local $sIP = "192.168.1.1" RunWait(@Comspec & ' /c netsh interface ipv4 set address name="Eternetas" static ' & $sIP & ' 255.255.255.0') Link to comment Share on other sites More sharing options...
Musashi Posted February 27, 2020 Share Posted February 27, 2020 (edited) 14 minutes ago, Huntknife said: The main question can Autoit do these things? You can also run the Batchfile from AutoIt (name.bat or name.cmd) : RunWait(@ComSpec & " /C " & "name.bat", "", @SW_SHOW) Change /C to /K to see, if an error is displayed in the CMD window. Edited February 27, 2020 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Huntknife Posted February 27, 2020 Author Share Posted February 27, 2020 Strange thing, i can load cmd file without error. But only thing that works is IP change, but not all three functions If i press 2 its still runs first function. Maybe have some ideas? Link to comment Share on other sites More sharing options...
Musashi Posted February 27, 2020 Share Posted February 27, 2020 45 minutes ago, Huntknife said: If i press 2 its still runs first function. Maybe have some ideas? This CMD jumps at least to the correct goto positions. You have to test if the respective commands are correct there. expandcollapse popup@echo off :menu echo. echo .......................... echo Spausti 1 - Change ip echo Spausti 2 - Start ping echo Spausti 3 - Open google chrome echo Spausti [ESC] - Quit echo .......................... echo. echo= IP Change: %IP% echo. set Modus=0 set /p modus="Enter Selection : " if %modus%==1 goto start if %modus%==2 goto ping if %modus%==3 goto chrome goto end :start echo. set /p IP= Change IP= netsh interface ipv4 set address name="Eternetas" static %IP% 255.255.255.0 echo. cls goto menu :ping echo. set /p Ping= Ping ip= echo. Ping %Ping% -t pause cls goto menu :chrome start "" www.google.com cls goto menu end: echo Script terminated pause "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Huntknife Posted February 27, 2020 Author Share Posted February 27, 2020 That worked well, thank you for help guys. Link to comment Share on other sites More sharing options...
Nine Posted February 27, 2020 Share Posted February 27, 2020 Instead of using this prehistoric DOS approach, I would recommend that you create a simple AutoIt GUI that can provide a more robust, secure interface. It only takes a few minutes, you could add some input verification and automate pretty much all you want within your script without relying to external program. Musashi and seadoggie01 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted February 27, 2020 Share Posted February 27, 2020 1 hour ago, Nine said: Instead of using this prehistoric DOS approach, I would recommend that you create a simple AutoIt GUI that can provide a more robust, secure interface. It only takes a few minutes, you could add some input verification and automate pretty much all you want within your script without relying to external program. Note: I only corrected the CMD, because it was part of the user question . In general, I agree with you 100% that an AutoIt-GUI is definitely the better and more reliable solution. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted February 27, 2020 Share Posted February 27, 2020 It was not aimed at you @Musashi nor at OP either. Was just a general comment. Sorry if it seems a bit harsh. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted February 27, 2020 Share Posted February 27, 2020 39 minutes ago, Nine said: It was not aimed at you @Musashi nor at OP either. Was just a general comment. Sorry if it seems a bit harsh. I didn't consider your remark to be harsh, otherwise I would not have given it a 'Like' . Sometimes answers will be provided, that are within the scope of the user question, although more appropriate solutions would be preferable. That is exactly what you did - you have suggested a better approach. Nine 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." 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