Export batch variables to php

Hewlett-packard / -
January 2, 2009 at 10:33:35
Specs: XP Sp3, centrino 4gb

I recently found a set of scripts that lets your u3 flashdrive send an email if it is stolen.

It consists of a batch file that autoruns from the flashdrive and a .php that needs to be on a server.
The batch file:

@echo off

rem Check if file with name '%COMPUTERNAME%' already exists
rem If so, skip
rem If not, create it and call home
start /min The adress of your php file?username:"%USERNAME%"__computername:"%COMPUTERNAME%"__domain:"%USERDOMAIN%"__dnsdomain:"%USERDNSDOMAIN%"__home:"%HOME%"

The php file:
$strTo = "youremail(at)address(dot)com";
$strSubject = "USB stick is calling home";
$strHeaders = "From: USB stick <youremail(at)address(dot)com>";
$strBodyText = "IP address: ".$_SERVER;
$strBodyText .= $_REQUEST;

mail($strTo, $strSubject, $strBodyText, $strHeaders);

<!-- This last line redirects to another site, hoping the 'user' doesn't notice anything -->
<meta http-equiv="refresh" content="0; url=http://www.google.com/">
From the website: http://www.ruwebit.net/article/197

I tried this but all I got in the email was:
IP address: ArrayArray

Is there a error in the script somewhere?

Is it possible to get send a custom variable from the batch file to the php script and use it in the email?

See More: Export batch variables to php

Report •

January 3, 2009 at 00:05:01
$_SERVER is an array of environmental variables and $_REQUEST is an array that contains $_GET, $_POST, and $_COOKIE variables (if they're set).

I *think* what you'd be after is something like

$strBodyText = "IP address: " . $_SERVER["REMOTE_ADDR"] . "\r\n";
foreach($_REQUEST as $key => $value) {
$strBodyText .= $key . " = " . $value . "\r\n";

I don't use batch scripts, so I have no idea on that question. Hope that helps a bit.

Good luck.

Report •
Related Solutions

Ask Question