14

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
Moby Disk
  • 3,761
  • 1
  • 19
  • 38
André Monteiro
  • 191
  • 2
  • 3
  • 10
  • 1
    You don't need to. Just set the homepage, then put it in Startup. – SLaks Apr 02 '15 at 01:02
  • 3
    possible duplicate of [Automatic login to a website on windows 7/Chrome via batch file](http://stackoverflow.com/questions/14204623/automatic-login-to-a-website-on-windows-7-chrome-via-batch-file) – SomethingDark Apr 02 '15 at 01:06
  • I know there are other ways man, but i want to do a program, it would be easier for her. And, sometimes my mom's email is logged in and i have to log off to connect with her's. It's complex for her, i just want to do a "Enter my email" program so she don't have to bother with these situations. – André Monteiro Apr 02 '15 at 01:07
  • I feel like setting up an RSS feed for her email and Facebook would be easiest. – SomethingDark Apr 02 '15 at 01:11
  • 1
    You can try creating two OS (assuming you're using a Windows platform) users (one for your grandma, one for your mother). Set the browser (Chrome/Firefox to open the pages opened in the last session and also log her into Facebook and e-mail and save the login credentials when asked). You'll achieve the same result and it is far easier and far simpler and far less zealous. When solving a problem always try to use all the available tools to find the simplest solution. – Radu Gheorghiu Apr 03 '15 at 11:35
  • You can set facebook and the email site to remember her account, then create shortcuts to them and place them on your desktop or someplace else =) –  Apr 20 '15 at 07:07
  • I need to do something similar for a headless (no input) system, but please don't do this on the typcial user machine. Set up a password manager (like LastPass) to store passwords in the browser, and just put bookmarks or shortcuts on the desktop for them to access the page. If you need multiple profiles, Chrome has great user-friendly profile tools. – brichins Jul 13 '16 at 19:12
  • hope this can help you [vbs auto login](https://stackoverflow.com/questions/14204623/automatic-login-to-a-website-on-windows-7-chrome-via-batch-file) – Earl Gail Galgao Gramaje Sep 07 '17 at 12:14

2 Answers2

9

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.

Community
  • 1
  • 1
Jouster500
  • 762
  • 12
  • 25
  • 1
    Was doing some additional testing and figured (and created) my own instant login to a specific email website. As a shortcut though, instead of doing %SendKeys% "{}" all the way through, i simply instead did %SendKeys% "Username{TAB}" %SendKeys% "Password{ENTER}" – Jouster500 Apr 20 '15 at 21:19
  • If you are using a JScript, then it would be easier to eliminate the batch file entirely and just do it all in a single JScript. – Moby Disk Apr 20 '15 at 21:30
  • That is true but there are certain competence levels you have to understand. See i know nothing about java yet i know enough about batch files to manipulate things relating to java. So you may be right, but at the same time its all based on the person who makes it and what they know. – Jouster500 Apr 21 '15 at 20:32
6

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));
Varun Ved
  • 339
  • 3
  • 6