Ing network drive vbs script

Source: Internet
Author: User
On Error Resume Next
Strremotepath = " \ UNC path "  
Strnewname = " Name to be displayed "

Set Objnetwork = Createobject ( " Wscript. Network " )
Set Coldrives = Objnetwork. enumnetworkdrives

For I = 0 To Coldrives. Count - 1 Step 2

Set Objshell = Createobject ( " Shell. Application " )
Strdriveletter = Coldrives. Item (I)
Strname = Objshell. namespace (strdriveletter). Self. Name
Strname = Left (Strname, Len (Strname) - 5 )
If Strname = Strnewname Then Wscript. Quit

Strdriveletter = CHR ( ASC ( Left (Coldrives. Item (I ), 1 )) - 1 ) & " : "

Next

If strdriveletter = " " then strdriveletter = " Z: "

' section to map the network drive
set objnetwork = Createobject ( " wscript. network " )
objnetwork. mapnetworkdrive strdriveletter, strremotepath

' section which actually (re) names the mapped drive
set objshell = Createobject ( " shell. application " )
objshell. namespace (strdriveletter ). self. name = strnewname

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.