Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get computer name and/or full network file path

Tags:

vbscript

Using Scripting.FileSystemObject I can get the full path name of a file, but this will always be like "c:\temp\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?

like image 562
Mr. Boy Avatar asked Jul 14 '10 09:07

Mr. Boy


People also ask

How do you find the full UNC path?

In Windows, if you have mapped network drives and you don't know the UNC path for them, you can start a command prompt (Start → Run → cmd.exe) and use the net use command to list your mapped drives and their UNC paths: C:\>net use New connections will be remembered.

How do I copy a full file path without a drive letter?

Hold Shift down and right-click on the file and select "Copy as path". Insert a Hyperlink in the email and paste in the address field of the Hyperlink dialogue box. After you create the hyperlink in the email, you're done. The link will show the mapped drive letter this is true.

What does \\ mean in Windows path?

They indicate that the path should be passed to the system with minimal modification, which means that you cannot use forward slashes to represent path separators, or a period to represent the current directory, or double dots to represent the parent directory.


1 Answers

Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName
WScript.Echo "Computer Name: " & strComputerName

Source: http://www.robvanderwoude.com/vbstech_network_names_computer.php:

like image 57
Chris Diver Avatar answered Nov 01 '22 14:11

Chris Diver