Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: how can I extract data and put it into a weblink using a batch file.  (Read 5071 times)

0 Members and 1 Guest are viewing this topic.

skofer

  • Guest
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

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: how can I extract data and put it into a weblink using a batch file.
« Reply #1 on: October 04, 2010, 06:43:42 AM »
I'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. 8)
« Last Edit: October 04, 2010, 07:08:56 AM by Sidewinder »
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

DaveLembke



    Sage
  • Thanked: 662
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: how can I extract data and put it into a weblink using a batch file.
« Reply #2 on: October 05, 2010, 12:12:47 PM »
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 " "


BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: how can I extract data and put it into a weblink using a batch file.
« Reply #3 on: October 06, 2010, 04:35:50 AM »
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.
I was trying to dereference Null Pointers before it was cool.