中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 15:59
47,811 topics / 349,897 posts / today 0 new / 48,255 members
DOS批处理 & 脚本技术(批处理室) » Please everyone test! Get the MAC and submit it to the web page!
Printable Version  2,400 / 13
Floor1 fbi Posted 2006-12-14 22:08
新手上路 Posts 8 Credits 15
Running mac.bat will generate the local MAC information into a c:\addmac.htm and run it. Using the automatic jump of this file, the MAC is submitted to mac.php for processing via GET!

It has been tested and works in win2003\xp\2000! But the c:\addmac.htm generated in win98 cannot save the MAC information

Please take a look at what the problem is!


:::mac.bat::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo
:::::::::If c:\ipconfig.txt exists, delete it
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::Run ipconfig /all command and save its content to ipconfig.txt
ipconfig /all >c:\ipconfig.txt

:::::::::If c:\MyMAC.txt exists, delete it
if exist c:\MyMAC.txt del c:\MyMAC.txt

:::::::::Query the line containing Physical Address in c:\ipconfig.txt and save this line to c:\MyMAC.txt
find "Physical Address" c:\ipconfig.txt >c:\MyMAC.txt

:::::::::If c:\addmac.htm exists, delete it
if exist c:\addmac.htm del c:\addmac.htm

::@echo <meta http-equiv="refresh" content="1;URL=http://192.168.1.1/mac.php?macinfo=">

echo "<meta http-equiv='refresh' content='1;URL=http://localhost:8080/mac/addmac.php?macinfo=" >>c:\addmac.htm

@echo off&setlocal enabledelayedexpansion
for /f "tokens=1* delims=:" %%a in (c:\MyMAC.txt) do (
set c=%%b
if not defined a (<nul set/p pp=!c:~1,17!>>c:\addmac.htm&set a=1) else (<nul set/p pp=!pp!^|!c:~1,17!>>c:\addmac.htm)
)

echo "'>" >>c:\addmac.htm
start "" c:\addmac.htm

:::::::::If c:\ipconfig.txt exists, delete it
if exist c:\ipconfig.txt del c:\ipconfig.txt

:::::::::If c:\MyMAC.txt exists, delete it
if exist c:\MyMAC.txt del c:\MyMAC.txt

exit
::End::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Floor2 HUNRYBECKY Posted 2006-12-14 22:58
银牌会员 Posts 442 Credits 1,179
Simply cannot obtain the MAC address at all
Floor3 HUNRYBECKY Posted 2006-12-14 23:00
银牌会员 Posts 442 Credits 1,179
There is a suggestion. If it's an internal network, can we change it to obtain the external network IP and then call OE to automatically send an email to the specified mailbox? In this way, we can obtain the IP in time for remote connection and control, and system maintenance will be more convenient. It feels like getting the MAC is not of much meaning.
Floor4 ccwan Posted 2006-12-14 23:03
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
I'm afraid the FBI has its own ideas, right?
Hehe...
Floor5 fbi Posted 2006-12-14 23:19
新手上路 Posts 8 Credits 15
Originally posted by fbi at 2006-12-14 09:08 AM:
Run mac.bat, which will generate a local MAC information into a c:\addmac.htm and run, using the automatic jump of this file, use GET to submit the MAC to mac.php for processing!

Tested feasible in win2003\xp\2000! But in win98 raw...


You look at the address bar after the addmac.htm jump parameters!
Floor6 HUNRYBECKY Posted 2006-12-14 23:34
银牌会员 Posts 442 Credits 1,179
http://localhost:8080/mac/addmac.php?macinfo="%20IPCONFIG.TXT|00-0E-A6-A0-73-86"
Floor7 HUNRYBECKY Posted 2006-12-14 23:34
银牌会员 Posts 442 Credits 1,179
So the MAC has come here.
Floor8 HUNRYBECKY Posted 2006-12-14 23:36
银牌会员 Posts 442 Credits 1,179
Can it be submitted to a fixed webpage or FTP?
Floor9 kcdsw Posted 2006-12-15 04:32
中级用户 Posts 179 Credits 404
```
@echo off & setlocal enabledelayedexpansion
del c:\addmac.htm >nul 2>nul

for /f "tokens=1" %%a in ('getmac /nh') do (
>>c:\addmac.htm echo "<meta http-equiv='refresh' content='1;URL=http://localhost:80/mac/addmac.php?macinfo="%%a"'>"
start "" c:\addmac.htm
goto start
)
:start
pause

```
Floor10 fbi Posted 2006-12-15 04:50
新手上路 Posts 8 Credits 15
Originally posted by HUNRYBECKY at 2006-12-14 10:34 AM:
http://localhost:8080/mac/addmac.php?macinfo="%20IPCONFIG.TXT|00-0E-A6-A0-73-86"


addmac.php separates the MAC separated by "|" from the GET submission and then saves the relevant information!

I wonder if you guys have any better methods!
Floor11 fbi Posted 2006-12-15 05:10
新手上路 Posts 8 Credits 15
But if there are multiple network cards (multiple MACs), it won't work!

[ Last edited by fbi on 2006-12-14 at 04:12 PM ]
Floor12 kcdsw Posted 2006-12-15 09:40
中级用户 Posts 179 Credits 404
You should take a look at the usage of getmac
Floor13 vkill Posted 2006-12-16 09:52
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
It's better to directly upload the .txt after ipconfig /all via FTP.
Floor14 tvzml Posted 2008-03-30 21:39
初级用户 Posts 67 Credits 157
@echo off & setlocal enabledelayedexpansion
del addmac.htm >nul 2>nul

For /F "tokens=2 delims=:" %%a in ('IpConfig /All^|Find /i "Physical Address. . . . . . . . . :"') do (
>>addmac.htm echo ^<meta http-equiv='refresh' content='1;URL=http://localhost:80/mac/addmac.php?macinfo="%%a"'^>
start "" addmac.htm
goto start
)
:start
pause
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023