Submitted By: Scott Haleen

Enables you to start a Google Internet Search from the command-line. Usage: cscript.exe google.js Search_Criteria.

Visual Basic
Edit|Remove
var srch = WScript.Arguments(0)
var iExp = new ActiveXObject("InternetExplorer.Application");
iExp.Navigate("about:blank");

while (iExp.Busy)
	WScript.Sleep(200);

iExp.Visible = 1;
	
var xmlHttp = false;
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

var url = "http://www.google.com/";

xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = function (){ 
    if(xmlHttp.readyState==4){ 
		var r = xmlHttp.responseText; 
		r = r.replace(/\/search/,url+'search');
		iExp.document.body.innerHTML = r;
		iExp.document.f.q.value = srch;
		iExp.document.f.submit();		
		};
    };
    
xmlHttp.send(null);

while (xmlHttp.readyState != 4)
	WScript.Sleep(200);

while(true) {
	WScript.StdOut.WriteLine('Enter Next Search Criteria (q to quit): ');
	srch = WScript.StdIn.ReadLine()
	if (srch=='q') 
		break;
	iExp.document.gs.q.value = srch;
	iExp.document.gs.submit();	
};