nemo1478 Posted January 5, 2018 Posted January 5, 2018 I only found out about AutoIt this week when I was searching for a way to auto login to various programs on my PC on a daily basis. Though I have no previous programming experience I was able to write my first script and it has been doing exactly what I wanted it to do except for one problem that I cannot figure out. I have 3 programs that I want to auto login to. I can of course run each program manually by clicking on the .bat file for each program and I can then log in with username and password without any issue but when I use the script, AutoIt can only open two of the programs. The third is giving me the following errors. "env.bat is not recognized as an internal or external command, operable program or batch file" and "windows cannot find javaw" I have checked and double checked the path for the program in question and it is correct. I just cannot figure out why it wont run. Here is the script I am trying to run; Run ("C:\FOLDER\oss\client\startup_all_global.bat") WinWaitActive ("Login") Send ("Password") Send ("!l") The script is supposed to run the .bat file which is located in that folder with that exact path and filename and launch the program. When the Login box appears the cursor is already flashing in the password box so the password is automatically entered then the enter key is hit with the "il" command. Problem is that the program fails to even launch. I know this has to be something very simple.
Nunos Posted January 5, 2018 Posted January 5, 2018 You may need to use ShellExecute() or ShellExecuteWait() for the .bat files.
KickStarter15 Posted January 5, 2018 Posted January 5, 2018 From Help: Example() Func Example() Local $sFile = ("C:\FOLDER\oss\client\startup_all_global.bat") ; Execute the .bat. Local $iPID = ShellExecute($sFile) WinWaitActive ("Login") Send ("Password") Send ("!l") EndFunc Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.
nemo1478 Posted January 5, 2018 Author Posted January 5, 2018 Thanks Nunos and KickStarter15 for your speedy responses but unfortunately the solution did not work. The same errors are being generated when I use ShellExecute() or ShellExecuteWait().
BrewManNH Posted January 5, 2018 Posted January 5, 2018 You might need to use the WorkingDir parameter to have it point to the same folder that the batch file is in. 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 GudeHow to ask questions the smart way! Reveal hidden contents 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
nemo1478 Posted January 5, 2018 Author Posted January 5, 2018 On 1/5/2018 at 2:31 PM, BrewManNH said: You might need to use the WorkingDir parameter to have it point to the same folder that the batch file is in. Expand I will check the help file and give it a try.
KickStarter15 Posted January 6, 2018 Posted January 6, 2018 Can you snippet to us your final code. Both functions "Run()" and " ShellExecute()" has the same function and might be you've missed something in your code. Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.
nemo1478 Posted January 7, 2018 Author Posted January 7, 2018 Run ("C:\U2000 DATACOM\client\startup_all_global.bat") WinWaitActive ("Login") Send ("Password") Send ("!l") Sleep (5000) Run ("C:\U2000 TRANSPORT\client\startup_all_global.bat") WinWaitActive ("Login") Send ("Password") Send ("!l") sleep (5000) Run ("C:\U2000 MOBILE\oss\client\startup_all_global.bat") WinWaitActive ("Login") Send ("Password") Send ("!l") This is the script I'm trying to run. The first two open fine but the third one refuses to open at all.
Developers Jos Posted January 7, 2018 Developers Posted January 7, 2018 On 1/7/2018 at 5:03 AM, nemo1478 said: This is the script I'm trying to run. The first two open fine but the third one refuses to open at all. Expand It should work when you can run if manually. Open up a CMD window, go to the directory of the 3rd batch file and type: dir *.bat (hit enter) and post the total text output of the cmd window so we can check. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
nemo1478 Posted January 7, 2018 Author Posted January 7, 2018 c:\>dir Volume in drive C has no label. Volume Serial Number is 463F-BFB9 Directory of c:\ 31/12/2017 11:52 PM <DIR> COMMAND'S SHORTCUT 25/12/2017 03:24 PM <DIR> Intel 13/12/2017 09:40 PM <DIR> PerfLogs 03/01/2018 07:41 AM <DIR> Program Files 03/01/2018 10:26 AM <DIR> Program Files (x86) 01/01/2018 10:53 PM <DIR> U2000 DATACOM 01/01/2018 10:53 PM <DIR> U2000 MOBILE 01/01/2018 10:58 PM <DIR> U2000 TRANSPORT 25/12/2017 07:18 PM <DIR> Users 05/01/2018 05:18 PM <DIR> Windows 0 File(s) 0 bytes 10 Dir(s) 205,985,652,736 bytes free c:\>cd u2000 mobile c:\U2000 MOBILE>dir Volume in drive C has no label. Volume Serial Number is 463F-BFB9 Directory of c:\U2000 MOBILE 01/01/2018 10:53 PM <DIR> . 01/01/2018 10:53 PM <DIR> .. 01/01/2018 10:56 PM <DIR> oss 0 File(s) 0 bytes 3 Dir(s) 205,985,517,568 bytes free c:\U2000 MOBILE>cd oss c:\U2000 MOBILE\oss>dir Volume in drive C has no label. Volume Serial Number is 463F-BFB9 Directory of c:\U2000 MOBILE\oss 01/01/2018 10:56 PM <DIR> . 01/01/2018 10:56 PM <DIR> .. 01/01/2018 10:53 PM <DIR> cau 01/01/2018 10:56 PM <DIR> client 01/01/2018 10:56 PM <DIR> jre 01/01/2018 10:56 PM <DIR> uninstall 0 File(s) 0 bytes 6 Dir(s) 205,985,452,032 bytes free c:\U2000 MOBILE\oss>cd client c:\U2000 MOBILE\oss\client>dir Volume in drive C has no label. Volume Serial Number is 463F-BFB9 Directory of c:\U2000 MOBILE\oss\client 01/01/2018 10:56 PM <DIR> . 01/01/2018 10:56 PM <DIR> .. 20/11/2016 09:39 AM 6,154 build_inc.xml 06/01/2018 10:46 PM <DIR> client 01/01/2018 10:56 PM <DIR> lib 01/01/2018 10:56 PM <DIR> logreview 01/01/2018 10:56 PM <DIR> notify 01/01/2018 10:56 PM <DIR> script 20/11/2016 09:39 AM 826 startup_all_global.bat 20/11/2016 09:39 AM 607 startup_all_global.sh 3 File(s) 7,587 bytes 7 Dir(s) 205,985,452,032 bytes free c:\U2000 MOBILE\oss\client>dir *.bat Volume in drive C has no label. Volume Serial Number is 463F-BFB9 Directory of c:\U2000 MOBILE\oss\client 20/11/2016 09:39 AM 826 startup_all_global.bat 1 File(s) 826 bytes 0 Dir(s) 205,985,054,720 bytes free c:\U2000 MOBILE\oss\client>
Developers Jos Posted January 7, 2018 Developers Posted January 7, 2018 That looks all perfect. So you still get an error on the 3rd script ? What is the exact error? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
nemo1478 Posted January 7, 2018 Author Posted January 7, 2018 On 1/7/2018 at 10:28 AM, Jos said: That looks all perfect. So you still get an error on the 3rd script ? What is the exact error? Jos Expand I have attached a pic of the error messages.
Earthshine Posted January 7, 2018 Posted January 7, 2018 (edited) Can’t find path to javaw.exe so its asking if java has been installed Edited January 7, 2018 by Earthshine My resources are limited. You must ask the right questions
Developers Jos Posted January 7, 2018 Developers Posted January 7, 2018 So there clearly is an issue with your batchfile. What about you try to supply clearer information in stead us trying to pull teeth here. SO: Show the batch file and tell us where env.bat is located. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
nemo1478 Posted January 12, 2018 Author Posted January 12, 2018 On 1/7/2018 at 4:03 PM, Jos said: So there clearly is an issue with your batchfile. What about you try to supply clearer information in stead us trying to pull teeth here. SO: Show the batch file and tell us where env.bat is located. Jos Expand I attached the batch file (startup_all_global.bat) that I'm trying to open with autoit but I am unable to find the location of the env.bat file it references. I did a Windows search but it returns no result. I find it strange that I can click on this file and it launches the program without any error but autoit cannot launch it, but then again clearly I don't understand how these things work. startup_all_global.bat
Developers Jos Posted January 12, 2018 Developers Posted January 12, 2018 No so strange assuming the Workdir isn't the same when launching from the command prompt. so this is your attached batchfile: echo off cd client\bin call env.bat cd .. REM when updated by cau, the file same with imap can not download to the client. add some remarks to change the file. start javaw -classpath .\startuploader.jar -Xdebug -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=40 -Xverify:none -Xms128m -Xmx256m -XX:MaxPermSize=128m -XX:PermSize=128m -XX:+UseSerialGC -Djava.util.Arrays.useLegacyMergeSort=true -Dsun.java2d.noddraw=true -Dhelpapp=run_help.bat -XX:+HeapDumpOnOutOfMemoryError -Djava.library.path=..\..\cau\lib;.\update\lib;..\lib;..\script\lib\core\itf;.\lib\dll;.\; -DExtesnionRigestry.debug=true -DExtesionRegistry.cacheUse=true -Dscript.name="%~fp0" -Dfile.encoding=UTF-8 -DSingleFileChooserPath=true com.swimap.startup.Startup -debuglevel 1 -showtrace false -enabledebug true -tracefile DebugTrace.txt %* cd .. In which directory are you located when running startup_all_global.bat ? According the batch file, that directory should contain directory client .... which then contains bin.... and this is correct reviewing your previous information. That directory should contain env.bat. So i guess all that needs to happen is change the Run() statement to: Run ("C:\U2000 MOBILE\oss\client\startup_all_global.bat","C:\U2000 MOBILE\oss\client") Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
nemo1478 Posted January 12, 2018 Author Posted January 12, 2018 On 1/12/2018 at 12:41 PM, Jos said: No so strange assuming the Workdir isn't the same when launching from the command prompt. so this is your attached batchfile: echo off cd client\bin call env.bat cd .. REM when updated by cau, the file same with imap can not download to the client. add some remarks to change the file. start javaw -classpath .\startuploader.jar -Xdebug -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=40 -Xverify:none -Xms128m -Xmx256m -XX:MaxPermSize=128m -XX:PermSize=128m -XX:+UseSerialGC -Djava.util.Arrays.useLegacyMergeSort=true -Dsun.java2d.noddraw=true -Dhelpapp=run_help.bat -XX:+HeapDumpOnOutOfMemoryError -Djava.library.path=..\..\cau\lib;.\update\lib;..\lib;..\script\lib\core\itf;.\lib\dll;.\; -DExtesnionRigestry.debug=true -DExtesionRegistry.cacheUse=true -Dscript.name="%~fp0" -Dfile.encoding=UTF-8 -DSingleFileChooserPath=true com.swimap.startup.Startup -debuglevel 1 -showtrace false -enabledebug true -tracefile DebugTrace.txt %* cd .. In which directory are you located when running startup_all_global.bat ? According the batch file, that directory should contain directory client .... which then contains bin.... and this is correct reviewing your previous information. That directory should contain env.bat. So i guess all that needs to happen is change the Run() statement to: Run ("C:\U2000 MOBILE\oss\client\startup_all_global.bat","C:\U2000 MOBILE\oss\client") Jos Expand That worked!!! Thank you so much Jos and to everyone else who contributed. Autoit can launch the program now. So let me get this straight. This run command tells Autoit to run the startup_all_global.bat file and also open/access/point to the "C:\U2000 MOBILE\oss\client" folder? And could I have specified the "C:\U2000 MOBILE\oss\client\bin" directly?
Developers Jos Posted January 12, 2018 Developers Posted January 12, 2018 On 1/12/2018 at 2:44 PM, nemo1478 said: So let me get this straight. This run command tells Autoit to run the startup_all_global.bat file and also open/access/point to the "C:\U2000 MOBILE\oss\client" folder? And could I have specified the "C:\U2000 MOBILE\oss\client\bin" directly? Expand Yes correct. Paths are relative to the Workdir or else you need to specify the full path and make it absolute. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
benched42 Posted January 12, 2018 Posted January 12, 2018 In my experience, the information in the help file for the Run command has been invaluable. The batch file should be run from a command prompt. In the help file we are told to use this command something like this: Run(@ComSpec & " /c " & "C:\FOLDER\oss\client\startup_all_global.bat") Who lied and told you life would EVER be fair?
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