【问题标题】:Get computer name and/or full network file path获取计算机名称和/或完整的网络文件路径
【发布时间】:2018-09-04 03:59:53
【问题描述】:

使用Scripting.FileSystemObject 我可以获得文件的完整路径名,但这总是像“c:\temp\myfile.txt”。如何获取 PC 的名称或文件的网络路径,如 \MyPC\temp\myfile.txt?除了Scripting.FileSystemObject,还有其他类我可以使用吗?

【问题讨论】:

    标签: vbscript


    【解决方案1】:
    Set wshNetwork = WScript.CreateObject( "WScript.Network" )
    strComputerName = wshNetwork.ComputerName
    WScript.Echo "Computer Name: " & strComputerName
    

    来源:http://www.robvanderwoude.com/vbstech_network_names_computer.php

    【讨论】:

    • 一行相同的命令 WScript.Echo CreateObject("WScript.Network").ComputerName
    【解决方案2】:

    这是一个单行答案,相当于 Chris 的answer

    WScript.Echo CreateObject("WScript.Network").ComputerName
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 2011-08-30
      • 2011-12-15
      • 1970-01-01
      相关资源
      最近更新 更多