//create the shell object.
var shell = new ActiveXObject("wscript.shell");

//use it to retrive the environment string username.
var userName = shell.ExpandEnvironmentStrings("%USERNAME%");

//alert it.
WScript.echo(userName);

//send a POST to x.php with the value user being the logged in user.
//must escape the username otherwise post will fail.
contactServer('http://192.168.0.99/za/x.php','user='+escape(userName));

//use the xmlhttprequest object to send the data to the server.
//data is sent using POST.
function contactServer(url,data){
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

//int the xmlhttprequest into post mode with the url.
xmlhttp.open("POST", url, false);

//form http header.
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

//register a function to run once the data is sent/response downloaded.
xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
  //stuff to run when data is recieved. atm just alerts whatever the webserver sends back.
   WScript.echo(xmlhttp.responseText)
  }
 }

//send the data.
xmlhttp.send(data);
}
