@echo off & setlocal enabledelayedexpansion
for /f "tokens=4" %%a in ('netsh interface show interface ^| findstr "已连接"') do set "ConName=%%~a"
echo 本机可上网网卡名称:%ConName%,回车直接输入默认可上网网卡名称
echo "以太网适配器 %ConName%"
set /p ConName=请输入可上网网卡名称:
for /f "tokens=1,2 delims=:" %%a in ('ipconfig') do (
if "%%a"=="以太网适配器 %ConName%" set "flag=1"
if "!flag!"=="1" (if "%%a"==" IPv4 地址 " set "ip=%%b")
)
echo IP=%ip%
pause
可以如下
Public Sub GetMyIP()
Dim strComputer As String
Dim objWMI As Object
Dim colIP As Object
Dim IP As Object
Dim i As Integer
strComputer = ""
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colIP = objWMIExecQuery _
("Select from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IP In colIP
If Not IsNull(IPIPAddress) Then
For i = LBound(IPIPAddress) To UBound(IPIPAddress)
MsgBox IPIPAddress(i), vbInformation, IPDescription(i)
Next
End If
Next
MsgBox "Excel版本信息为:" & ApplicationCalculationVersion
MsgBox "Excel当前允许使用的内存为:" & ApplicationMemoryFree
MsgBox "Excel当前已使用的内存为:" & ApplicationMemoryUsed
MsgBox "Excel可以使用的内存为:" & ApplicationMemoryTotal
MsgBox "本机 *** 作系统的名称和版本为:" & ApplicationOperatingSystem
MsgBox "本产品所登记的组织名为:" & ApplicationOrganizationName
MsgBox "当前用户名为:" & ApplicationUserName
MsgBox "当前使用的Excel版本为:" & ApplicationVersion
End Sub
VBA网抓常用方法
1、xml>
@echo Off & setlocal Enabledelayedexpansion & mode 65,15
>>$ ipconfig /all
>>$1 findstr /i "IPv4" "$" & move $1 $ & cls
>>$1 (for /f "tokens=2 delims=:" %%a in ($) do (
set/a str_step+=1 & set str=
set "str=%%a" & set str=!str:^(=! & set str=!str: =!
set str=!str:首选=! & set str=!str:^)=!
echo !str!))
move $1 $ & cls & set str_step= & echo(
for /f "delims=" %%a in ($) do (
set/a str_step+=1
echo !str_step!%%a)
echo & set/p ips= 请选择 IP :
for /f "delims=" %%a in ($) do set/a step+=1
if !ips!==0 (exit) else if !ips! gtr !step! exit
set str_step=
for /f "delims=" %%a in ($) do (
set/a str_step+=1
if !str_step!==!ips! set "ipstr=%%a")
echo 您的IP则是: !ipstr!
pause>nul
:: 中国批处理脚本联盟
:: 已经将您的 IP 赋值给了 ipstr 这个变量, 你可以加以应用!
方法1:
1、对着桌面的“网络”,右键--属性
2、点击“更改适配器设置”
3、找到你连接的网络,右键--状态
4、点击“详细信息”
5、里面的物理地址就是你的网卡地址END
方法2:
点击开始菜单,输入cmd,回车
在命令行中输入ipconfig/all
回车
方法3:
找到你的网络连接,物理地址就是你的网卡地址
分类: 电脑/网络 >> 软件
问题描述:
我正在开发一个B/S版的营运系统,系统要求当用户通过浏览器登陆系统时,能得到用户电脑网卡的MAC地址,不知道如何能够实现
该系统是用VBNET写的一个ASPNET程序
解析:
<%
strIP = RequestServerVariables("REMOTE_ADDR")
strMac = GetMACAddress(strIP)
strHost = RequestServerVariables("REMOTE_HOST")
Function GetMACAddress(strIP)
Set = ServerCreateObject("wscriptneork")
Set sh = ServerCreateObject("wscriptshell")
shrun "%spec% /c nbtstat -A " & strIP & " > c:" & strIP & "txt",0,true
Set sh = nothing
Set fso = createobject("scriptingfilesystemobject")
Set ts = fsoopentextfile("c:" & strIP & "txt")
macaddress = null
Do While Not tsAtEndOfStream
data = ucase(trim(tsreadline))
If instr(data,"MAC ADDRESS") Then
macaddress = trim(split(data,"=")(1))
Exit Do
End If
loop
tsclose
Set ts = nothing
fsodeletefile "c:" & strIP & "txt"
Set fso = nothing
GetMACAddress = macaddress
End Function
%>
<HTML>
<HEAD>
<TITLE>Say Hello To the MAC MAN</TITLE>
</HEAD>
<BODY>
<%ResponseWrite("Your IP is : " & strIP & "<BR>" & vbcrlf)%>
<%ResponseWrite("Your MAC is : " & strMac & vbcrlf)%>
</BODY>
</HTML>
后记:此程序中需要USER_用户有C盘的写入权限,也可以将文中的“C:”改为有写权限的驱动器(或目录)也可。
以上就是关于我写了一个BAT脚本获取指定网卡的IP地址,但是一直不成功,求大佬帮我看看全部的内容,包括:我写了一个BAT脚本获取指定网卡的IP地址,但是一直不成功,求大佬帮我看看、VBA是否可以获得当前计算机IP地址和计算机名、怎么用VBA或网络爬虫程序抓取网站数据等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)