开发者

Get computer name and/or full network file path

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜