2007-08-28

Automatic Login to google with WScript.

WScript is the short name for Windows Script. It can be a VBScript or JScript(not Javascript but a Microsoft standard!) If we use it properly, it can save us a lot of work. Here is an example for a script which can be used to login in google account automaticly.

var ie=WScript.createobject("InternetExplorer.Application");
var args = WScript.arguments;
var followme="http://www.google.com/";
if(args.length>0)
{
followme
+=args(0);
}
ie.Navigate(
"https://www.google.com/accounts/Login?continue="+followme);
SynchronizeIE();
var doc=ie.document;
doc.forms[
0].Email.value="yourName@gmail.com";
doc.forms[
0].Passwd.value="^your password";

//because the checkbox "PersistentCookie" appears randomly
if(doc.forms[0].PersistentCookie!=null)
{
doc.forms[
0].PersistentCookie.checked=false;
}
doc.forms[
0].submit();
SynchronizeIE();
ie.Visible
=true;

//wait for IE finishs its job
function SynchronizeIE()
{
while(ie.Busy)
{
WScript.Sleep(
100);
}
}

Save the code as googleSpecific.js and make it under the %windir%\system32, then create a file called google.bat under the same path with the content:

@cls

@wscript %windir%\system32\googleSpecific.js %1 %2 %3 %4 %5 %6 %7 %8 %9

After that, execute "google mail" in command promp, you can log in your gmail directly now.

Other commands are:
google notebook
google bookmarks
If you type "google" without any parameters, you will sign in with the google.com.

5 comments:

Anonymous said...

cool thanks

Anonymous said...

I inclination not acquiesce in on it. I assume precise post. Specially the title attracted me to read the whole story.

Anonymous said...

Genial brief and this post helped me alot in my college assignement. Thank you on your information.

Anonymous said...

Easily I to but I about the post should have more info then it has.

Unknown said...

Hey, but it works only for ie. How if I want it to work in Mozilla ? Any idea ? Please reply.