+ Post New Thread
Results 1 to 8 of 8
How do you do....it? Thread, I need a VB Script to Map a Drive in Technical; I have some Surface RT devices and Asus Transformers. Neither can join the domain but I would like to map ...
  1. #1

    fiza's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    2,124
    Thank Post
    418
    Thanked 314 Times in 265 Posts
    Rep Power
    153

    I need a VB Script to Map a Drive

    I have some Surface RT devices and Asus Transformers. Neither can join the domain but I would like to map network drives. Mapping the drives requires the user to input a username and password to authenticate. I have used a batch file but this doesnt hide the password as it is typed. I was hoping someone may have a vb script that would allow this?

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,696
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Is this a manual add, or automated? Just from your "as it's typed comment"

    Steve

  3. #3

    fiza's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    2,124
    Thank Post
    418
    Thanked 314 Times in 265 Posts
    Rep Power
    153
    Quote Originally Posted by Steve21 View Post
    Is this a manual add, or automated? Just from your "as it's typed comment"

    Steve
    Manual - I want the user to login to the Surface and then click on a VB Script to run it to map the drives. Like I said I have a batch script that does this but the password is in clear text which is not ideal.

  4. #4

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,696
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    If you use batch file with net use: it'll hide the password by default, unless you really want vbscript?

    Steve

  5. #5

    fiza's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    2,124
    Thank Post
    418
    Thanked 314 Times in 265 Posts
    Rep Power
    153
    @Steve21 - Not too hot on scripts but this is what I currently have. When the user types the password it is shown on screen.

    set /p User=Enter your three letter logon ID:
    CLS
    set /p Password=Enter the password you normally logon with:
    CLS

    NET USE P: "\\server\share1" /user:domain\%User% %Password%
    NET USE I: "\\server\share2" /user:domain\%User% %Password%

  6. #6

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,696
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    If you don't ask it to take a password it'll automatically ask you for one, and hide the input.

    Code:
    net use Z: \\netadmin-sd1\c$ /user:"domain"\sdrew
    The password is invalid for \\netadmin-sd1\c$.
    
    Enter the password for '"domain"\sdrew' to connect to 'netadmin-sd1':
    System error 1326 has occurred.
    
    Logon failure: unknown user name or bad password.
    Obviously wont work as I cba to put password in, but it doesn't show what I typed

    Would mean you have to type it twice, if you're doing two at once though

    Steve

  7. Thanks to Steve21 from:

    fiza (11th December 2013)

  8. #7

    fiza's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    2,124
    Thank Post
    418
    Thanked 314 Times in 265 Posts
    Rep Power
    153
    Quote Originally Posted by Steve21 View Post
    If you don't ask it to take a password it'll automatically ask you for one, and hide the input.

    Code:
    net use Z: \\netadmin-sd1\c$ /user:"domain"\sdrew
    The password is invalid for \\netadmin-sd1\c$.
    
    Enter the password for '"domain"\sdrew' to connect to 'netadmin-sd1':
    System error 1326 has occurred.
    
    Logon failure: unknown user name or bad password.
    Obviously wont work as I cba to put password in, but it doesn't show what I typed

    Would mean you have to type it twice, if you're doing two at once though

    Steve
    Thats done it!!! Thanks. User will have to type it twice.

  9. #8


    Join Date
    Mar 2009
    Location
    Leeds
    Posts
    6,592
    Thank Post
    228
    Thanked 856 Times in 735 Posts
    Rep Power
    296
    i have a script on here that works. p.s. forget vbs on rt its crippled to the point of uselessness

    Code:
    echo off
    rem mapdrive prompt v3 20-09-13
    net use r: /delete
    net use u: /delete
    net use v: /delete
    
    set /p str=Enter Username: 
    rem echo %str%
    set str2=%str:~0,1%
    rem echo %str2%
    rem echo %stra%
    rem decide what year group by first character
    if  %str2%==1 goto equals1
    if  %str2%==2 goto equals2
    if  %str2%==3 goto equals3
    if  %str2%==4 goto equals4
    if  %str2%==5 goto equals5
    if  %str2%==6 goto equals6
    if  %str2%==7 goto equals7
    if  %str2%==8 goto equals8
    if  %str2%==9 goto equals9
    if  %str2%==0 goto equals0
    
    rem echo not 0-9 so presumably staff
    
    net use u: \\server\users$\staff\%str% /user:%str% *
    net use r: \\server\resources$
    net use v: \\server\users$
    
    rem echo %mapu%
    
    goto end
    
    :equals1
    net use u: \\server\users$\2011\%str% /user:%str% *
    net use r: \\server\resources$
    
    goto end
    
    :equals2
    net use u: \\server\users$\2012\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals3
    net use u: \\server\users$\2013\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals4
    net use u: \\server\users$\2014\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals5
    net use u: \\server\users$\2015\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals6
    net use u: \\server\users$\2006\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals7
    net use u: \\server\users$\2007\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals8
    net use u: \\server\users$\2008\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals9
    net use u: \\server\users$\2009\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :equals0
    net use u: \\server\users$\2010\%str% /user:%str% *
    net use r: \\server\resources$
    goto end
    
    :end
    
    pause

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. Replies: 4
    Last Post: 7th May 2013, 12:25 PM
  3. Replies: 4
    Last Post: 12th February 2012, 11:26 PM
  4. Replies: 0
    Last Post: 5th July 2011, 11:24 PM
  5. Replies: 13
    Last Post: 22nd April 2011, 03:50 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •