I have a 70 years old grandma that is not used to use the computer, but she has an e-mail and Facebook, and every time she wants to access those sites i have to help her through the process. So, i got an idea, i know a little of programing, so i tried to do a batch file to automatize this process of opening Firefox, typing "www.exemple.com", and login in her account. With this she could at least see if there are any emails or facebook notifications, but i could just do an batch to open the email site, i would like to know if there is any way to do a program to login.
Batch File:
ECHO OFF
START FIREFOX "WWW.EXAMPLE.COM" "WWW.EXAMPLE2.COM"
EXIT
Figured this out today, how one can use batch files on windows computers to push keyboard commands to websites or other applications if needed. See here for the original coding information.
The core of the command that you will find here simply results as
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
%SendKeys% "{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
While i myself am still experimenting and testing this batch file program on different applications, i am not sure as to the inner-workings of what this program actually does. All i know is it uses a java script installed on every windows computer to push keyboard commands to be executed. However in my experimentation i found that it could also serve as a means to fill in passwords and usernames.
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START FIREFOX "WWW.EXAMPLE.COM"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 5
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.
%SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "{U}"
%SendKeys% "{s}"
%SendKeys% "{E}"
%SendKeys% "{r}"
%SendKeys% "{N}"
%SendKeys% "{a}"
%SendKeys% "{M}"
%SendKeys% "{e}"
%SendKeys% "{TAB}"
%SendKeys% "{P}"
%SendKeys% "{4}"
%SendKeys% "{S}"
%SendKeys% "{S}"
%SendKeys% "{W}"
%SendKeys% "{O}"
%SendKeys% "{R}"
%SendKeys% "{D}"
%SendKeys% "{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Thus logging your grandmother into the specific website. While this is a rough approximate of the code i would have attempted running, it should still work. If it doesn't, start from scratch with the link i provided. In addition, if you need ways to include those special characters check here as well.
*EDIT:
I later made something like this for myself and found a simpler way instead of typing out all those %SendKeys%. You can simply do
%SendKey% "Username{TAB}"
%SendKey% "Password{ENTER}"
as a more simpler way of going through the login process. The only downside to any of this is that if she decides to change her login, you would have to change her password from within the program.
This worked for me actually, I referred jouster500 answer, there were few bugs which I rectified, works like a charm.
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START CHROME "https://login.classy.org/"
rem the script only works if the application in question is the active window. Set a
timer to wait for it to load!
timeout /t 10
rem use the tab key to move the cursor to the login and password inputs. Most htmls
interact nicely with the tab key being pressed to access quick links.
rem %SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "{TAB}"
%SendKeys% "{TAB}"
%SendKeys% "username"
%SendKeys% "{TAB}"
%SendKeys% "password"
%SendKeys% "{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
Related
im trying to automate a ssh connetcion to a NAS in order to wake up a computer using WOL.
All goes fine until i try to enter the root password required for the wake command
start cmd.exe #cmd /k "ssh admin#xxx.xxx.xxx.xxx"
ping localhost -n 2
%SendKeys% "xxxxxxxxxx"
%SendKeys% "{ENTER}"
ping localhost -n 5
%SendKeys% "sudo synonet --wake xx:xx:xx:xx:xx:xx eth0"
%SendKeys% "{ENTER}"
%SendKeys% "xxxxxxxxxx"
%SendKeys% "{ENTER}"
this is the result of the above code
strange enough, the ssh password is entered correctly but calling %SendKeys% "{ENTER}" after the wake command cause strange excape characters entered causing the command to fail.
Is there some way to avoid this side effects? Thanks in advance.
i tried the code above but i cannot figure out why it displays strange characters.Also other methods like putty are useless because cannot automatically enter the root password after the command.
I have two batch files as below, and I want to merge them in to one btach file? (I don't want to run them seperately want to one click to run)
First one delete and copy file, second one is opens chrome and login. These batch files working properly one by one when I clicked. But I need one batch file.
Thanks for your help..
First one is:
#echo off
del "C:\web.config"
copy "C:\\Web - New.config" "C:\web.config"
Second one one is:
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START CHROME "http://localhost:15000/"
rem the script only works if the application in question is the active window. Set a
timer to wait for it to load!
timeout /t 2
rem use the tab key to move the cursor to the login and password inputs. Most htmls
interact nicely with the tab key being pressed to access quick links.
rem %SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "admin"
%SendKeys% "{TAB}"
%SendKeys% "1234"
%SendKeys% "{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
When you have two batchfiles, batch1.bat and batch2.bat and you want both of them to run in one batchfile, the simpliest solution is to create this batchfile:
call batch1.bat
call batch2.bat
There's absolutely no problem running a batchfile from another batchfile!
I want to automate an application. On calling this application (Which starts from a batch file) it shows up a command prompt window in which it asks for values.
By values I mean :-
First, it will ask you to hit ENTER (Can ENTER be automated?)
Then it asks for a path (String, of course)
Then it asks again for another path (String, again)
How can I pass these values to the command prompt using any script/batch/tool/Java program?
Right now these values has to be entered manually, I want to automate this procedure. So, here I don't want to enter them manually, I want a script to do it. Is it possible? If yes, how?
This is a copy of the solution at this post, but adjusted for your particular needs. First, the "application.bat":
#echo off
set /P "=Hit ENTER to continue"
set /P "aPath=Enter a path: "
set /P "anotherPath=Enter another path: "
echo/
echo I read "%aPath%" and "%anotherPath%"
Then , the solution:
#if (#CodeSection == #Batch) #then
#echo off
echo Start the Batch file
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
rem Start the "application" in the same Window
start "" /B cmd /C application.bat
rem Wait and send the first ENTER
ping -n 2 -w 1 localhost > NUL
%SendKeys% "{ENTER}"
rem Wait and send the first path
ping -n 2 -w 1 localhost > NUL
%SendKeys% "C:\The\first\path{ENTER}"
rem Wait and send the second path
ping -n 2 -w 1 localhost > NUL
%SendKeys% "D:\A\Second\Path{ENTER}"
goto :EOF
#end
// JScript section
WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
The output:
Start the Batch file
Hit ENTER to continue
Enter a path: C:\The\first\path
Enter another path: D:\A\Second\Path
I read "C:\The\first\path" and "D:\A\Second\Path"
How can I start a batch file in full-screen mode? I know that this question was asked before, but it wasn't actually answered.
unfortunately, I don't know reverse engineering, so I cant decompile the code.
Here is something I tested:
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
start cmd.exe
%sendkeys% "(%{enter})"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
The idea is that it starts a cmd window, and (this part of the code %sendkeys% "(%{enter})") is supposed to simulate the user pressing [alt] + [enter]. But it doesn't work.
I wrote a little c# tool to send an alt+enter to the cmd window, but I'm looking for an internal method.
If sendkeys parameter for "Alt-Enter" should be "%{enter}", then this line:
%sendkeys% "(%{enter})"
... should have not parentheses and there is one percent sign missing. Try:
%sendkeys% "%%{enter}"
See the example for "Alt-V" at this post
I made an autoIT script, extremely simple.
Run("cmd.exe")
sleep (1000)
Send("!{enter}")
Unfortunately, this isn't what I want. I was looking for more of an actual command, not some other 3d party program.
:: edit
here: This is a link to the compiled 1 line skiddy script that I made.
Its a command line tool, so all you have to do is type fullscreen in a cmd window to toggle fullscreen mode.
In case you don't know how to use a command line tool, you have to be in the same directory as the file.
i need to create a batch file which opens a website(gmail) and enters username and password.
so can anyone help me please..
Thank you.
here is the code i tried.. It opens gmail, now how can i enter username and password.
saved as Test.bat
#echo off
start /d "C:\Program Files\Internet Explorer" IEXPLORE.EXE https://gmail.com
Won't let me comment, but I agree the batch is the wrong way to do this. You could do this with PowerShell though.
add-type -AssemblyName microsoft.VisualBasic
add-type -AssemblyName System.Windows.Forms
#Loads Website
C:\Progra~1\Intern~1\iexplore.exe -k http://www.gmail.com
#Enter Credentials
[System.Windows.Forms.SendKeys]::SendWait("userid{TAB}password{enter}")
You cannot do this. You can open a specific url, but you cannot enter values in a form.
You can open an e-mail adress from the command prompt, but that will open the default e-mail client, and not some webmail page. So unfortunately, it's not possible.
I don't think there's a purely-batch way of achieving your goal.
You may try to write something up, using, for example, http://jsoup.org/ . But you'll need to change your code every time there's a new specification on the page.
This can be done with Selenium. You need to write a simple Selenium JUnit test in Java. Of course, this requires that Java be installed on the computer. It would be about 20-30 lines of code. Then, you can execute the JUnit test from a batch file like so:
#ECHO off
SET username=me
SET password=mypassword
java -cp MyGmailTest.class MyGmailTest %username% %password%
timeout 10
Use selenium's firefox WebDriver with java.
http://docs.seleniumhq.org/download/
Import all the necessary webDriver librarys, and it will very simple. Something like this:
public class checkEmail{
public static void main(String args[]){
WebDriver driver = new FirefoxDriver();
driver.get("www.gmail.com");
driver.findElement(By.id("Email")).sendKeys("your usernamne");
driver.findElement(By.id("Passwd")).sendKeys("your password");
driver.findElement(By.id("signIn")).click();
}
}
get the .class files, then make a simple batch file
#ECHO OFF
set CLASSPATH= (wherever your selenium jars are)
cd C:\where ever the class file is
java checkEmail
WITH FIREFOX:
#echo off
set command=C:\Users\%USERNAME%\Desktop\GMAIL.VBS
start https://gmail.com
echo Set objShell = WScript.CreateObject("WScript.Shell") > %command%
echo Set WshShell = WScript.CreateObject("WScript.Shell") >> %command%
echo Do Until Success = True >> %command%
echo Success = objShell.AppActivate("Mozilla Firefox") >> %command%
echo Loop >> %command%
echo WshShell.SendKeys "USERNAME HERE" >> %command%
echo WshShell.SendKeys "{TAB}" >> %command%
echo WshShell.SendKeys "[PASSWORD HERE] >> %command%
echo WshShell.SendKeys "{ENTER}" >> %command%
ping 192.0.2.2 -n 1 -w 5000 > nul
start %command%
ping 192.0.2.2 -n 1 -w 1000 > nul
del %command%
exit
chance [USERNAME HERE] AND [PASSWORD] { with the [ ] }
WITH GOOGLE CHROME
#echo off
set command=C:\Users\%USERNAME%\Desktop\GMAIL.VBS
start https://gmail.com
echo Set objShell = WScript.CreateObject("WScript.Shell") > %command%
echo Set WshShell = WScript.CreateObject("WScript.Shell") >> %command%
echo Do Until Success = True >> %command%
echo Success = objShell.AppActivate("Google Chrome") >> %command%
echo Loop >> %command%
echo WshShell.SendKeys "USERNAME HERE" >> %command%
echo WshShell.SendKeys "{TAB}" >> %command%
echo WshShell.SendKeys "[PASSWORD HERE] >> %command%
echo WshShell.SendKeys "{ENTER}" >> %command%
ping 192.0.2.2 -n 1 -w 5000 > nul
start %command%
ping 192.0.2.2 -n 1 -w 1000 > nul
del %command%
exit
chance [USERNAME HERE] AND [PASSWORD] { with the [ ] }
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
%SendKeys% "{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
While i myself am still experimenting and testing this batch file program on different applications, i am not sure as to the inner-workings of what this program actually does. All i know is it uses a java script installed on every windows computer to push keyboard commands to be executed. However in my experimentation i found that it could also serve as a means to fill in passwords and usernames.
#if (#CodeSection == #Batch) #then
#echo off
rem Use %SendKeys% to send keys to the keyboard buffer
set SendKeys=CScript //nologo //E:JScript "%~F0"
START FIREFOX "WWW.EXAMPLE.COM"
rem the script only works if the application in question is the active window. Set a timer to wait for it to load!
timeout /t 5
rem use the tab key to move the cursor to the login and password inputs. Most htmls interact nicely with the tab key being pressed to access quick links.
%SendKeys% "{TAB}"
rem now you can have it send the actual username/password to input box
%SendKeys% "username{TAB}"
%SendKeys% "password{ENTER}"
goto :EOF
#end
// JScript section
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.SendKeys(WScript.Arguments(0));
check this