My AutoIt script:
WinWaitActive("User Authentication","","10")
If WinExists("User Authentication") Then
; Enter a username.
Send("prabu{TAB}")
Send("{TAB}")
;Enter a Password.
Send("Password")
Send("{TAB}")
Send("{SPACE}")
;Press Authenticate button.
Send("{TAB} {ENTER}")
EndIf
It waits for an authentication popup window to gain focus,
enters a username and password,
then presses the "Authenticate" button.
I "compiled" it to an .exe file and execute it from Selenium using:
Runtime.getRuntime().exec("C:\\Users\\Prabu\\Documents\\ds.exe");
But I want it to enter a different username and password every time. I intend to provide these to the script using command-line arguments (parameters if you will).
Is it possible to pass arguments/parameters to AutoIt scripts? If so, how should this be done and how do I access arguments/parameters provided to my script?
changes in AutoIt Script
$username = $CmdLIne[1]
$password=$CmdLine[2]
Send($username)
Send($password)
in java
String command="C:\\Users\\Prabu\\Documents\\ds.exe \"username1\" \"password1\"";
Runtime.getRuntime().exec(command);
reference
https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
http://seleniumocean.blogspot.in/2014/11/its-time-for-autoit-parameterizing.html
Related
Part of my program's job is to create a new user account, elevate it to admin, and then run programs AS that user.
To do this, I would use the following code:
runas /user:hostname\AddedUserProfile /savecred program.exe
This works, but there is a problem. To use the runas command, the user you are running the program through, must have a password. Upon running the command, it asks you for that user's password. My program is supposed to run behind the scenes, and without the user being able to see it (Don't worry. I already have code that invisibly starts programs, so that is NOT the issue here). I can't find a way to automatically enter text into the password entry field (and yes, I know the password doesn't show visibly). I've tried having the program echo the password, and I've even tried to have it rerout the output of an echo command, into the input of the password field.
echo password | runas /user:hostname\AddedUserProfile /savecred program.exe
Even that doesn't work! it just gives me an error:
RUNAS ERROR: Unable to run - taskmgr.exe
-2147467259: Unspecified error
I really am at my wit's end on this one. If there is a way to do this other than runas, I'd LOVE to know! I'd prefer that it was using runas, though.
Edit:
It seems that the error is due to an incorrect password entry. I can't figure out why it would be entering it incorrectly, however. If I do not use the /savecred, then I get an error message that actually says that the password is incorrect.
Auto input password by using a pipe method like this:
echo PasswordHere | runas /user:hostname\AddedUserProfile /savecred program.exe
That mean, it will type "PasswordHere" when runas.exe need user input. I'm not tested it yet, so you have to try it out. I always use this "pipe" way to access my FTP server.
I have a batch script which runs a command:
certreq -submit -attrib "CertificateTemplate:WebServer" CSR.csr CRT.crt
This produces a dialog box to named as "Select Certificate Authority" with OK and cancel button, I need to proceed with OK to complete that command. Can I do it with command to close the box by processing it with OK?
you can try with sendkeys.bat:
call sendkeys.bat "certificate" "{enter}"
The first argument is the title of the window you want to process and the second is the string you want to send to it.Here you can find an info what special characters you can send.
I used autoit tool to get it done. It is simple to use.
Below are the autoit commands.
WinWaitActive("Certification Authority List")
WinWaitActive("Certification Authority List")
ControlClick("Certification Authority List","OK","[CLASS:Button; INSTANCE:1]")
I have an application ,i want to run on using task scheduler .
now i want to set up execution through command line arguments on my local system.
i created set up but ask password i need to enter that password dynamically i.e from file are as arguments etc.
Please suggest me any solutions to skip password option or to enter password dynamically.
Does this answer your question? It explains how to call a batch file with command line parameters.
How do I pass command line parameters to a batch file?
I have a batch file (lets say "test.bat"). Now when we run this test.bat it asks for user inputs during it's execution, For ex. user credentials and then shows a menu. The user can choose an option from the menu by entering a value after which the script will ask him for a lot more product specific details.
Question:
I need to call this test.bat inside another batch file and whenever test.bat requires user inputs my batch script should be able to provide a some inputs (a known sequence of menu options and inputs).
Is there anyway I can achieve this?
To call another batch file, I refer this link:
Several ways to call a windows batch file from another one or from prompt. Which one in which case?
To get user inputs:
Echo off
set /p x=path name:
echo path is %x%
pause
I want to write a simple bat script but I cannot deal with one thing.
I run a command and it gives few messages and it's waiting for my login. I want to write a script which will do it.
For example, I run a command:
myCommand.bat
and it gives:
msg1...
msg2...
...
type your login:_
Now, I have to put my login.
How can I do it automatically?
BAT script is the best way for me :)
You probably can solve this by either
placing your username and/or password directly in myCommand.bat
placing your username and/or password in a file "myPassword.txt" and using redirection: <myPassowrd.txt myCommand.bat
But, you probably should not do either of those for security reasons.
Addendum:
If your batch script is calling an executable that is prompting for the login credentials, you may have 2 options
The executable may have a command line option(s) that allows you to specify username
and/or password. You would have to research your executable to find out what they are.
If the executable is not expecting any other input, you might be able to pipe the username and/or password into the program. For example, if the program asks for username and then asks for password, something like this might work:
(echo yourName&echo yourPassword)|yourProgram.exe
Security concerns still apply