1.

Solve : how can I extract data and put it into a weblink using a batch file.?

Answer»

Hello all,
I would like to extract DATA like pcname, serial number then have it placed into a weblink so my PHP code can use it to put it into a form.
I think I'm close. I just need some help.

example:
start iexplore "http://www.mysite.com/index.php?serial_number=(GOTO serial)&computer_name=%computername%"
:serial
wmic bios get serialnumber

Any help would be GREAT. Thank youI'm fairly certain you cannot place NT commands in a parameter list and expect them to be executed. More likely the GOTO will be SEEN by the interpreter as a series of four alpha characters and simply pass them on to IE. Even if it did work, you'd more likely need to use Call in this situation.

An alternative would be to extract the serial number using WMIC prior to starting IE and then use VARIABLE substitution (much like you did with %computername%) to resolve the parameters to IE.

Code: [Select]@echo off
for /f %%i in ('wmic bios get serialnumber') do set serial=%%i
start iexplore "http://www.mysite.com/index.php?serial_number=%serial%&computer_name=%computername%"

The for statement is generic. You may need to tweak it for parsing depending on the actual output of WMIC. If you run into problems, please run wmic bios get serialnumber from the command line and post the complete output including any blank lines.

Good luck. The closest thing to extraction of info from a batch would be to >> it to a *.dat file at which another program would read in that file contents and use the contents to operate. Many languages have the ability to do this without the need for batch, but if you want to use batch this is a start. Another program other than batch would assemble this information into a usable URL and you would put the URL within the " " like the batch below. You could also have the other language assemble the batch dynamically by writing out to a *.bat file and then execute it.

cd\.
cd program files\internet explorer\
iexplore.exe "www.hak5.org"

Normally iexplorer.exe cant be executed from your default prompt, but by pointing your prompt to start in the root of the internet explorer you can then launch IE and URL pointer tagged on within " "

Quote from: skofer on October 03, 2010, 12:29:37 PM

Hello all,
I would like to extract data like pcname, serial number then have it placed into a weblink so my PHP code can use it to put it into a form.
I think I'm close. I just need some help.

example:
start iexplore "http://www.mysite.com/index.php?serial_number=(GOTO serial)&computer_name=%computername%"
:serial
wmic bios get serialnumber

Any help would be great. Thank you

First, I have no idea how to parse something with eols using for/f (as wmic does for it's output), so, I created a small VBS script that makes that parsing easier:

getserial.vbs
Code: [Select]Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")
Dim colSettingsBios : Set colSettingsBios = objWMI.ExecQuery("Select * from Win32_BIOS")
Dim objComputer, strModel, strSerial
For Each objComputer in colSettings
strModel = objComputer.Model
Next
For Each objComputer in colSettingsBios
strSerial = objComputer.SerialNumber
Next
wscript.echo strSerial

batch file that uses the above and shells iexplore:

Code: [Select]for /f "tokens=*" %%P in ('cscript /nologo getserial.vbs') do set Serial=%%P
start iexplore "http://www.mysite.com/index.php?serial_number=%Serial%&computer_name=%computername%"



and then of course in the PHP you would access them via the $_GET array:

Code: [Select]$Serial=$_GET["serial_number"];
$compname=$_GET["computer_name"];


you would place the batch and the VBSCRIPT in the same folder, and run the batch to execute this.


Discussion

No Comment Found