Using Scripting.FileSystemObject
I can get the full path name of a file, but this will always be like "c:\tem开发者_StackOverflow社区p\myfile.txt". How can I get the name of the PC, or a network-path to the file like \MyPC\temp\myfile.txt? Is there another class other than Scripting.FileSystemObject
I can use?
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName
WScript.Echo "Computer Name: " & strComputerName
Source: http://www.robvanderwoude.com/vbstech_network_names_computer.php:
This is a single line answer that is equivalent to Chris's answer
WScript.Echo CreateObject("WScript.Network").ComputerName
精彩评论