Public Function strGetNodeID()
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.run "cmd /c ipconfig/all >c:\NodeID.txt", 1, True
Set WshShell = Nothing
Dim fso, thefile, ln
Set fso = CreateObject("Scripting.FileSystemObject")
Set thefile = fso.OpenTextFile("c:\NodeID.txt", 1)
Do While thefile.atendofstream <> True
ln = thefile.ReadLine
If InStr(ln, "Physical Address") <> 0 Then
ln = Right(ln, 18)
Exit Do
End If
Loop thefile.Close
fso.DeleteFile ("c:\NodeID.txt")
Set fso = Nothing
strGetNodeID = Replace(ln, "-", "")
End Function经查可能是WshShell.run "cmd /c ipconfig/all >c:\NodeID.txt", 1, True,在win2003下没有生成记事本,但是在运行中直接键入 "cmd /c ipconfig/all >c:\NodeID.txt"能正确生成,望赐教,谢谢
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.run "cmd /c ipconfig/all >c:\NodeID.txt", 1, True
Set WshShell = Nothing
Dim fso, thefile, ln
Set fso = CreateObject("Scripting.FileSystemObject")
Set thefile = fso.OpenTextFile("c:\NodeID.txt", 1)
Do While thefile.atendofstream <> True
ln = thefile.ReadLine
If InStr(ln, "Physical Address") <> 0 Then
ln = Right(ln, 18)
Exit Do
End If
Loop thefile.Close
fso.DeleteFile ("c:\NodeID.txt")
Set fso = Nothing
strGetNodeID = Replace(ln, "-", "")
End Function经查可能是WshShell.run "cmd /c ipconfig/all >c:\NodeID.txt", 1, True,在win2003下没有生成记事本,但是在运行中直接键入 "cmd /c ipconfig/all >c:\NodeID.txt"能正确生成,望赐教,谢谢
参考一下:community.csdn.net/Expert/topic/4640/4640618.xml?temp=.605633
win2003不行怎么解决呢,很急啊
这段代码在win2003 是可以的,我已经测试过。