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"能正确生成,望赐教,谢谢

解决方案 »

  1.   

    shell "cmd /c ipconfig/all >>c:\NodeID.txt", vbhide
      

  2.   

    使用WMI吧
    参考一下:community.csdn.net/Expert/topic/4640/4640618.xml?temp=.605633
      

  3.   

    WshShell.run "cmd /c ipconfig/all >c:\NodeID.txt", 1, True,这句在win2000下是好的,在
    win2003不行怎么解决呢,很急啊
      

  4.   

    你试试:Shell "cmd /c ipconfig/all >c:\NodeID.txt"
      

  5.   

    试过了,不行啊,就是无法生成txt文件,周末都不让愉快啊
      

  6.   

    Shell "cmd /c ipconfig/all >c:\NodeID.txt"
    这段代码在win2003 是可以的,我已经测试过。