mac怎么创建vbs

mac怎么创建vbs,第1张

vbs 内容如下:

'Option Explicit

Const ForReading= 1,ForWriting = 2,ForAppending = 8

Dim fso,file,msg

Dim WshShell,Path_init_file

Dim routmac,routip,routmask,routgw

Dim rinmac,rinip,rinmask,ringw

Dim k,m

Set WshShell=WScriptCreateObject( "WScriptShell")

Path_init_file=left(WscriptScriptFullName,len(WscriptScriptFullName)-len(WscriptScriptName))& "nicinfoini"

'msgbox(path_init_file)

Set fso=CreateObject("ScriptingFileSystemObject")

Set file=fsoOpenTextFile(Path_init_file,ForReading)

While (Not fileAtEndOfLine)

msg=fileReadLine

msg=trim(msg)

if instr(msg,"outmac:")>0 then

k = InStr(msg, ":")

m = Len(msg)

routmac = Right(msg, m - k)

'msgbox(routmac)

else

end if

if instr(msg,"outip:")>0 then

k = InStr(msg, ":")

m = Len(msg)

routip = Right(msg, m - k)

'msgbox(routip)

else

end if

if instr(msg,"outmask:")>0 then

k = InStr(msg, ":")

m = Len(msg)

routmask = Right(msg, m - k)

'msgbox(routmask)

else

end if

if instr(msg,"outgw:")>0 then

k = InStr(msg, ":")

m = Len(msg)

routgw = Right(msg, m - k)

'msgbox(routgw)

else

end if

如果是在网页上执行脚本,为安全考虑,你会没有权限获取这些信息。

如果是在本地磁盘运行vbs脚本,可以调用系统的WMI服务进行硬件查询:

Dim objWMIService

Set objWMIService = Getobject("winmgmts:\\\root\cimv2")

Dim objNetworks, objNetwork, objNetworks_2, objNetwork_2, NetWorkInfo

NetWorkInfo = ""

Set objNetworks = objWMIServiceexecQuery("Select From

Win32_NetworkAdapter")

Set objNetworks_2 = objWMIServiceexecQuery("Select

From Win32_NetworkAdapterConfiguration")

For Each objNetwork In

objNetworks

If objNetworkManufacturer <> "Microsoft" And Not

Isnull(objNetworkMACAddress) Then

For Each objNetwork_2 In

objNetworks_2

If objNetwork_2Index = objNetworkIndex

Then

NetWorkInfo = "网卡信息:" & objNetworkDescription & ","

& objNetwork_2IPAddress(0) & _

Space(17-Len(objNetwork_2IPAddress(0))) & _

Replace(objNetwork_2MACAddress,":","-") & "☆"

Exit

For

End If

Next

If NetWorkInfo <> "" Then

Exit For

End If

Next

代码如下:

Dim str,nstr,i, k, j

str = InputBox("请输入MAC地址,使用英文冒号分隔地址" & chr(13) & "00:0e:be:ca:eb:8a")

nstr = Replace(str, ":", "")

For i = 1 To len(nstr) Step 4

    k = Mid(nstr, i, 4)

    If Len(k) = 4 And i < 9 Then 

        j = j & k & ""

    Else 

        j = j & k

    End If

Next

MsgBox "文本一内容为"&j&Chr(13)&"文本二mac地址累加内容为"&jDim fso, f

Set fso = CreateObject("ScriptingFileSystemObject")

Set f = fsoOpenTextFile("C:\testtxt") '引号里自己改文件路径

fWriteLine("")  '引号里自己改内容,引号去除后就是写入变量

fClose

set wmi=GetObject("winmgmts:\\\root\CIMV2")

set w=wmiExecQuery("select from win32_processor")

a="CPU名称"

for each i in w

a=a & vbcrlf & iName

next

set w=wmiExecQuery("select from win32_ComputerSystem")

a=a & vbcrlf & vbcrlf & "内存大小"

for each i in w

a=a & vbcrlf & iTotalPhysicalMemory

next

set w=wmiExecQuery("select from win32_DiskDrive")

a=a & vbcrlf & vbcrlf & "硬盘大小"

for each i in w

a=a & vbcrlf & iSize

next

set w=wmiExecQuery("select from win32_LogicalDisk where DriveType='3'")

a=a & vbcrlf & vbcrlf & "盘符----大小"

for each i in w

a=a & vbcrlf & iDeviceID & " ---- " & iSize

next

set w=wmiExecQuery("select from win32_NetworkAdapter")

a=a & vbcrlf & vbcrlf & "网络适配器"

for each i in w

a=a & vbcrlf & iProductName

next

Set w = wmiExecQuery("Select from Win32_NetworkAdapterConfiguration Where IPEnabled=True")

a=a & vbcrlf & vbcrlf & "MAC地址"

For Each i in w

a=a & vbcrlf & iMACAddress

Next

set w=wmiExecQuery("select from win32_VideoController")

a=a & vbcrlf & vbcrlf & "显卡型号----显存"

for each i in w

a=a & vbcrlf & iName & " ---- " & iAdapterRAM

next

Set FSO = CreateObject("ScriptingFileSystemObject")

set f=fsoopentextfile("xinxitxt",2,true)

fwrite "电脑信息:" & vbcrlf & vbcrlf & a

fclose

msgbox "OK"

说明:程序运行约2s(因为读取硬件信息)

部分程序命令可能出错(电脑禁用)

结果保存为“xinxitxt”

以上就是关于mac怎么创建vbs全部的内容,包括:mac怎么创建vbs、vbs怎么获取本地网卡连接名(求代码)、vbsd出窗口请输入mac地址:,输入后转换格式输出到文本等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9307542.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存